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

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 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内容进行处理后。问题解决。