尝试使用 PHP 解析格式不正确的 UTF-8 xml 文件
我正在尝试解析 XML 文件,但 XML 文件有一处格式不正确。我尝试过很多很多的皈依者之类的东西,但没有任何帮助。首先我尝试使用 simplexml,然后尝试使用 XMLReader,但出现错误:“解析器错误:输入不是正确的 UTF-8,指示编码!字节:0x0C 0x41 0x62 0x6F”。
在将 xml 内容放入 simplexml 之前,是否有一个技巧可以首先操作它?或者有谁有更好的 XML 解析器,可以处理格式不正确的 xml 字符串?
谢谢 尼克
I am trying to parse an XML File, but there is one place where the XML file is not well formed. I have try many many converts and stuff, but nothing helps. As first I have try with simplexml, then I have try with XMLReader, but I become ever the error: "parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0x0C 0x41 0x62 0x6F" .
Is there a trick, where I can manipulate the xml content as first, before I put it into simplexml? Or has anyone a better XML parser, who works with not well formed xml strings?
Thanks
Nik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 DOmDocument 取得了一些成功:
加载文档后,您可以调用一些函数来尝试清理它, DomDocument
I have used DOmDocument with some success:
After you have loaded the doc there are some functions you can call that will try to clean it up, DomDocument