Php adds the CDATA label when generating xml. How to add CDATA labels when php generates xml this article describes how to add CDATA labels when php generates xml. Share it with you for your reference. The specific implementation method is as follows: in fact, the method for adding the CDATA tag when php generates xml files
This example describes how to add the CDATA tag when php generates xml. Share it with you for your reference. The specific implementation method is as follows:
In fact, the method of adding CDATA labels when php generates xml is very simple, because it is a tag that can store various content in xml. The following is an example to help you.
Code, truth, and code. $textIt can be a tag.
The code is as follows:
The code is as follows:
$ Dom = new DOMDocument ("1.0 ");
// Display document in browser as plain text
// For readability purposes
Header ("Content-Type: text/plain ");
// Create root element
$ Root = $ dom-> createElement ("toppings ");
$ Dom-> appendChild ($ root );
// Create child element
$ Item = $ dom-> createElement ("item ");
$ Root-> appendChild ($ item );
// Create text node
$ Text = $ dom-> createTextNode ("pepperoni ");
$ Item-> appendChild ($ text );
// Create attribute node
$ Price = $ dom-> createAttribute ("price ");
$ Item-> appendChild ($ price );
// Create attribute value node
$ PriceValue = $ dom-> createTextNode ("4 ");
$ Price-> appendChild ($ priceValue );
// Create CDATA section
$ Cdata = $ dom-> createCDATASection ("Customer requests that pizza be sliced into 16 square pieces ");
$ Root-> appendChild ($ cdata );
// Create PI
$ Pi = $ dom-> createProcessingInstruction ("pizza", "bake ()");
$ Root-> appendChild ($ pi );
// Save and display tree
Echo $ dom-> saveXML ();
?>
Examples in this article describes how to add the CDATA tag when php generates xml. Share it with you for your reference. The specific implementation method is as follows: in fact, php generation...