Php 加载包含未转义字符的xml
我是PHP新手:) 我正在尝试加载包含未转义字符的XML。我想用正则表达式。有谁能告诉我,如何正确地做这件事吗 这是我的简单XML文件:Php 加载包含未转义字符的xml,php,xml,regex,Php,Xml,Regex,我是PHP新手:) 我正在尝试加载包含未转义字符的XML。我想用正则表达式。有谁能告诉我,如何正确地做这件事吗 这是我的简单XML文件: <?xml version="1.0" encoding="utf-8"?> <test> <url>http://example.com?T=2&P=1</url> </test> 我收到这个错误: "simplexml_load_string(): Entity: line 3
<?xml version="1.0" encoding="utf-8"?>
<test>
<url>http://example.com?T=2&P=1</url>
</test>
我收到这个错误:
"simplexml_load_string(): Entity: line 3: parser error : EntityRef: expecting ';'"
有什么想法吗?试着用XML封装数据:
<?xml version="1.0" encoding="utf-8"?>
<test>
<url><![CDATA[http://example.com?T=2&P=1]]></url>
</test>
还要考虑@Rakesh Sharma comment来使用simplexml_load_file()
为什么不使用simplexml\u load\u file()
<?xml version="1.0" encoding="utf-8"?>
<test>
<url><![CDATA[http://example.com?T=2&P=1]]></url>
</test>