A small question about php processing xml
Encountered a small problem
Assume that the content of a variable is as follows:
$ Test ="
11111111
11111111
1111
text
test
111111
";
$ PostObj = simplexml_load_string ($ test, 'simplexmlelement', LIBXML_NOCDATA );
Use simplexml_load_string to read xml into the variable
$ PostObj-> addChild ("id", "123 ");
I added an element
How can we restore the content in the variable to xml format?
Reply to discussion (solution)
You can write it back.
$ Test = $ postObj-> saveXML ();
However, please note that you have the LIBXML_NOCDATA parameter when you open it, so there will be no CDATA nodes written back.
You can write it back.
$ Test = $ postObj-> saveXML ();
However, please note that you have the LIBXML_NOCDATA parameter when you open it, so there will be no CDATA nodes written back.
Confused. I just read the PHP SimpleXML function for a long time.
I always thought that saveXml is used to save xml as a file... thank you.