XML解析_处理异常...基本的PHP问题 [英] XML parsing _ dealing with an exception ... basic PHP problem

查看:94
本文介绍了XML解析_处理异常...基本的PHP问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用PHP编写了一个运行良好的XML解析器... 使用

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

$ xml = simplexml_load_file($ newfile);

$xml = simplexml_load_file($newfile);

现在,新文件是指向超过20000行的xml文件的指针.
问题是,系统(一个android系统)开始生成名为

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 >

...不存在任何值时... 但是,没有< /none>标签...有多个<没有>值! 好像是
a)要么指示Android不要这样做! -尝试过,但是无法控制.. OS处理它.

... 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),或者,创建一个PHP漏洞来防止此错误!

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

我需要帮助.我该如何实现?

I need help. How do I achieve this ?

谢谢

推荐答案

如果没有结束标记-xml无效.如果只有 none 标记存在问题,您可以尝试在解析器中忽略它.甚至在处理解析器之前,尝试使用php"preg_replace"功能删除 none 标签,例如preg_replace.

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

这篇关于XML解析_处理异常...基本的PHP问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆