惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
博客园 - 【当耐特】
H
Help Net Security
腾讯CDC
大猫的无限游戏
大猫的无限游戏
GbyAI
GbyAI
Last Week in AI
Last Week in AI
Jina AI
Jina AI
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
Y
Y Combinator Blog
C
Check Point Blog
博客园 - 司徒正美
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - flyingchen

gcc的一个困惑 敏捷项目组 javascript string to date - flyingchen 熟悉了以下VIM指令,你会爱死她的 ajax应用如何做好seo - flyingchen - 博客园 nestful - ruby http-rest 客户端 分析 Liskov替换原则与继承 Linux Commands Cannot find autoconf. Please check your autoconf installation pecl报错(1) - flyingchen - 博客园 关于角色访问控制(RBAC) awk学习 php实现单件模式总结(持续更新) 激动网 PHP高级开发工程师 招聘 rsync的命令格式 rsync从linux到linux的文件同步备份 zend + apache + config stop words mmseg 安装错误 error: ’strncmp’ was not declared in this scope
post xml 通过 simplexml_load_string 解析问题 - flyingchen
flyingchen · 2010-03-18 · via 博客园 - flyingchen

将如下$xml = "<?xml version='1.0' encoding='utf-8'?>

<address>
<street>Lot 11, Happy Street</street>
<state>Florida</state>
<country>USA</country>
</address>

";  post到服务器,服务器端通过simplexml_load_string解析,报

代码

Warning:  simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : String not started expecting ' or " in C:\AppSer\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:\AppSer\.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:\AppSer\process.php on line 14

Warning:  simplexml_load_string() [function.simplexml

-load-string]: Entity: line 1: parser error : Blank needed here in C:\AppSer\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:\AppSer\process.php on line 14

Warning:  simplexml_load_string() [function.simplexml

-load-string]: Entity: line 1: parser error : parsing XML declaration: '?>' expected in C:\AppSer\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:\AppSer\process.php on line 14

错误。

通过最初的排查,我认为是因为字符被html格式化了,即通过

htmlspecialchars — Convert special characters to HTML entities方式。

所以我尝试,通过

htmlspecialchars_decode — Convert special HTML entities back to characters 

方式将其格式化回来。但错误依旧。

 通过google发现别的同志也遇到过这样的问题,分析出原因在于引号处理上。

通过

stripslashes — Un-quotes a quoted string

将post内容进行处理后。问题解决。