Php generates xml, which is not easy to understand and online! PHPcode & lt ;? Php $ xml_str = & lt; eof & lt ;? Xmlversion = '1. 0 '? & Gt; & lt; books & gt; & lt; book & gt; & lt; title & gt; The xml generated by HarryPo php contains one simple question, not understanding, online, etc!
PHP code
Harry Potter
Warner Bros.
39.0
eof;$dom = new DOMDocument;$dom->loadXML($xml_str);echo $dom->saveXML();$dom->save("0000.xml");?>
This is the xml page generated by php. the xml name is pai.xml.
Now the problem arises. if any of the above nodes is empty, add them. 39.0 Change
There is a problem with the generated xml file. let's take a look at the generated 0000. xml content and open the browser with an editor:
XML code
Harry Potter
Warner Bros.
[color=#FF0000]
[/color]
Please help me see what is going on, because the node content in the xml file I want to generate is not clear, and some node values will be left blank. if it is php, it cannot generate content with Null nodes,
I want some nodes to be empty and the generated xml file can be as follows:
XML code
Harry Potter
Warner Bros.
[color=#FF0000]
[/color]
Thank you for helping me. I wish you a happy day!
------ Solution --------------------
First It should be written
Next, try saveHTML ()
------ Solution --------------------
$ Dom-> save ("mirror.xml", LIBXML_NOEMPTYTAG); // The last sentence is changed to this.
------ Solution --------------------
I don't know. A null value may cause a problem.
------ Solution --------------------
It is best to add For example: <! [CDATA [Harry Potter]>
Also pay attention to the symbols <,>, &, \, "to be converted to <> & '", and to be converted to spaces. Otherwise, an error is returned.
------ Solution --------------------
What's the problem ?!
Empty nodes in XML
You can write like
You can also write like