【发布时间】:2012-01-04 23:19:48
【问题描述】:
我正在使用 XmlSlurper 解析一个脏的 html 页面,我收到以下错误:
ERROR org.xml.sax.SAXParseException: Element type "scr" must be followed by either attribute specifications, ">" or "/>".
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
...
[Fatal Error] :1157:22: Element type "scr" must be followed by either attribute specifications, ">" or "/>".
现在,我有 html 供我输入并在此之前打印它。如果我打开它并尝试转到错误中提到的行 1157,那里没有“src”(但文件中有数百个这样的字符串)。所以我猜想插入一些额外的东西(可能是<script> 或类似的东西)会改变行号。
有没有什么好的方法可以准确地找到有问题的行或 html 片段?
【问题讨论】:
-
错误提到“scr”,你是说你找不到“src”。这是一个错字,还是您在文档中搜索错误的内容?
-
在找到 NekoHTML 之前,我也在使用 TagSoup。我不记得确切的原因,但 TagSoup 只是没有解决。您可以在此处查看如何使用 NekoHTML 的示例 - stackoverflow.com/questions/9260461/…。
标签: html groovy xerces xmlslurper