Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 加载包含未转义字符的xml_Php_Xml_Regex - Fatal编程技术网

Php 加载包含未转义字符的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

我是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: 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>