Php generates xml, which is not understandable,

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.