PHP中的XML替换内容无效
我有这样一个无效的XMLPHP中的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中不
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);