如何使用未转义的 & 符号解析 XML [英] How to parse XML with unescaped ampersand

查看:36
本文介绍了如何使用未转义的 & 符号解析 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须读取大型(大约 200MB)XML 文件,我正在使用 xmlreader 和 PHP.有一个带有未转义符号的节点 URL.解析总是在第一个 url 节点上停止.我使用的编码 windows-1250 与 XML 文件的 xml 标签中指定的相同.

I have to read large (about 200MB) XML file, I'am using xmlreader with PHP. There is node URL with unescaped ampersand in it. Parsing always stops on first url NODE. I'm using encoding windows-1250 same as is specified in xml tag of XML file.

我收到错误:解析器错误:EntityRef:期望';'在

是否可以使用 & 解析 XML?NODE 的价值?

Is it possible to parse an XML with & in value of NODE ?

感谢您的任何提示,如果您需要,我可以分享代码.

Thank you for any tips, I can share a code if you need.

推荐答案

是否可以使用 & 解析 XML?NODE 的价值?

Is it possible to parse an XML with & in value of NODE ?

不,这意味着该文件根本不是格式良好的 XML,因此并不真正符合 XML 文件的要求,并且没有 XML 文件解析器可以处理这种情况,否则它就不是 XML 解析器.

No, that means the file is not well-formed XML at all therefore does not really qualify as an XML file and no XML file parser can deal with that otherwise it would not be an XML parser.

但是,您可以在将数据传递给 XML 解析器之前对其进行预处理并自行解决问题 (& -> &).

However you can pre-process the data before you pass it to an XML parser and fix the issue (& -> &) your own.

这篇关于如何使用未转义的 & 符号解析 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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