Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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,我有这样一个无效的XML Warning: count() [function.count]: Node no longer exists in /var/bla/test.php <?xml version="1.0" encoding="ISO-8859-1"?> <nodes> <some>test</some> </nodes> 警告:count()[function.count]:节点在/var/bla/test.php中不

我有这样一个无效的XML

Warning: count() [function.count]: Node no longer exists in /var/bla/test.php
<?xml version="1.0" encoding="ISO-8859-1"?>
<nodes>
<some>test</some>
</nodes>
警告:count()[function.count]:节点在/var/bla/test.php中不再存在
测试
现在我需要一个正则表达式,它将用
替换/var/bla/test.php中不再存在的
警告:count()[function.count]:节点
我该怎么做

上面的xml不是在我的本地计算机上生成的,它是一个api调用,返回了无效的xml错误报告(0)

可能有答案


简而言之,如果您想使用属性或节点的值,可以转换为字符串。

坚持您的问题,只需删除该文件的第一行。

假设出于某种原因必须使用正则表达式,这行PHP删除了从字符串开始到第一次出现
的所有内容。也许解决错误而不是隐藏消息会是更好的方法?@nickf提醒我。它不在我的本地计算机上,而是从api中删除的
$output = preg_replace('/\A.*?<\?xml/s', '<?xml', $input);