The page contains html text to submit and process XMLcodexml. The local format is as follows & lt; aaurl & quot; www.xxx.com & quot; & gt; & lt ;! [CDATA [& lt; fontsize & quot; 13 & quot; & gt; & lt; ahref & quot; www.xxx.com? Xs & amp; f3 & quot; target page contains html text for submission and processing
XML code
// The local xml format is as follows: 常 见 问 答1<br/><br/> 常 见 问 答2<br/><br/> 常 见 问 答3<br/><br/>
The correct format in the above xml
If you want to modify the value, I will first retrieve the value under the aa node and then submit it directly to report an error.
I used htmlspecialchars encoding and submitted it to the xml node. although no error is reported, the following error is displayed.
XML code
<font size="13"<<a href="www.xxx.com?x=s&f=3" target="_blank"<常 见 问 答1</a></font<<br/<<br/<
What should I do if I want to submit a value containing html tags to an xml node?
------ Solution --------------------
The content in CDATA does not need to be escaped! The escape is wrong.
------ Solution --------------------
XML code
Frequently Asked Question 1
FAQ 2
FAQ 3
------ Solution --------------------
Do not use htmlspecialchars encoding later
------ Solution --------------------
In php. ini, is the magic_quotes_gpc () function enabled? The quotation marks are automatically escaped ..
------ Solution --------------------
Use XmlWriter to write CDATA
------ Solution --------------------
By the way, stick it to you.
PHP code
$ Str = <
http://www.google.com
http://www.yahoo.com
XML; $ xml = simplexml_load_string ($ str, 'simplexmlelement', LIBXML_NOCDATA); header ('content-type: application/XML'); $ xw = new XMLWriter (); $ xw-> openMemory (); $ xw-> startDocument ('1. 0 ', 'utf-8'); $ xw-> startElement ('root'); foreach ($ xml-> url as $ item) {// modify $ xw-> startElement ('URL'); $ xw-> writeCdata ($ item. 'ABC'); $ xw-> endElement ();} $ xw-> endElement (); echo $ xw-> outputMemory ();