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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS 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内容进行处理后。问题解决。