Php adds the phpxmlcdata label when generating xml. Php adds the CDATA tag when generating xml. phpxmlcdata tag 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: php adds the CDATA tag when generating xml, phpxmlcdata tag
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:
<? Php
$ 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 ();
?>
I hope this article will help you with php programming.
How does php extract the content of CDATA in xml?
You can try to use simpleXml to parse this file, which is much simpler than EXpat.
Who used Xstream to generate xml with cdata labels to parse xml with cdata labels?
In XML, CDATA indicates that internal data is not escaped, that is, characters such as <,> are not interpreted.
When parsing such xml, the interpreter reads its content as is without any special processing.
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...