Post xml parsing through simplexml_load_string

Source: Internet
Author: User

Add the following $ xml = "<? Xml version = '1. 0' encoding = 'utf-8'?>

<Address>
<Street> Lot 11, Happy Street </street>
<State> Florida </state>
<Country> USA </country>
</Address>

"; Post to the server, the server parses through simplexml_load_string, and reports

Code Warning: simplexml_load_string () [function. simplexml-load-string]: Entity: line 1: parser error: String not started expecting 'or "in C: \ Cycler \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: <? Xml version = \ "1.0 \" encoding = \ "UTF-8 \"?> In C: \ AppSer \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: ^ in C: \ javaser \. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: Entity: line 1: parser error: Malformed declaration expecting version in C: \ AppSer \. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: <? Xml version = \ "1.0 \" encoding = \ "UTF-8 \"?> In C: \ AppSer \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: ^ in C: \ javaser \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: Entity: line 1: parser error: Blank needed here in C: \ javaser \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: <? Xml version = \ "1.0 \" encoding = \ "UTF-8 \"?> In C: \ AppSer \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: ^ in C: \ javaser \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: Entity: line 1: parser error: parsing XML declaration: '?> 'Expected in C: \ javaser \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: <? Xml version = \ "1.0 \" encoding = \ "UTF-8 \"?> In C: \ AppSer \ process. php on line 14

Warning: simplexml_load_string () [function. simplexml-load-string]: ^ in C: \ javaser \ process. php on line 14

Error.

Through the initial troubleshooting, I think it is because the characters are formatted in html, that is

Htmlspecialchars-Convert special characters to HTML entities.

So I tried

Htmlspecialchars_decode-Convert special HTML entities back to characters

Format it back. But the error persists.

Google found that other comrades had encountered such a problem and analyzed the reason for the quotation marks.

Pass

Stripslashes-Un-quotes a quoted string

After processing the post content. Solve the problem.

 

Related Article

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.