How can I handle page submission containing html text?

Source: Internet
Author: User
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
             &lt;font size="13"&lt;&lt;a href="www.xxx.com?x=s&f=3" target="_blank"&lt;常 见 问 答1&lt;/a&gt;&lt;/font&lt;&lt;br/&lt;&lt;br/&lt;      


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 ();
     

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.