XML parsing _ dealing with an exception … basic PHP problem

旧巷老猫 提交于 2019-12-11 16:59:54

问题


I have written a perfectly working XML parser using PHP... using,

$xml = simplexml_load_file($newfile);

Now, The newfile was a pointer to an xml file that has over 20000 lines.
The problem was, the system ( an android) started generating tags called

< none >

... when no value existed... BUT, there is NO < /none > tag ... There are multiple < none > values !! It seems like
a) Either instruct Android not to do this ! - TRIED, but it can't be controlled .. OS deals with it.

b) or, Create a PHP loophole to prevent this error !

I need help. How do I achieve this ?

Thanks


回答1:


If there no end tag - xml is not valid. If there only issue with none tag you can try ignore it in your parser. Or even try remove none tags with php "find and replace" functions like preg_replace before dealing with parser



来源:https://stackoverflow.com/questions/5495543/xml-parsing-dealing-with-an-exception-basic-php-problem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!