【发布时间】:2021-10-30 19:21:21
【问题描述】:
我正在解析来自 web 服务的 xml 文件,偶尔会遇到此错误:
xml2:::read_xml.raw(rs$content) # where the object rs is the response from the webservice, obtained using the httr package
Error in read_xml.raw(x, encoding = encoding, ...) :
xmlParseCharRef: invalid xmlChar value 2 [9]
我下载了数千个 xml,只有少数损坏了。 '
我的问题是:
如何定位导致错误的响应中的字符。 修复由无效 xmlChars 引起的无效 xml 的一般策略是什么?
我已经通过将响应解析为 html 来解决问题,但我宁愿修复问题并解析为 xml
谢谢!
【问题讨论】: