我正在尝试使用 JDOM 解析以下 XML:
<ASX version = "3.0" BANNERBAR="fixed">
<TITLE>HM FM 104.5</TITLE>
<ENTRY>
<TITLE>HM FM 104.5</TITLE>
<BANNER HREF = "http://xxx.xxx.xx.xxx:89/asxbanner.jpg">
<moreinfo href = "http://www.nch.com.au/index.html" />
<abstract>Click here to go to http://www.nch.com.au/index.html</abstract>
</BANNER>
<REF HREF = "http://xxx.xxx.xx.xxx:89/broadwave.mp3?src=1&rate=1&ref=http%3A%2F%2Fxxx.xxx.xx.xxx%3A89%2F" />
</ENTRY>
</ASX>
我的问题是包含“src=1&rate=1&ref=http%3A%2F”的行似乎导致以下异常:
Caused by: org.xml.sax.SAXParseException: The reference to entity "rate" must end with the ';' delimiter.
这是代码:
SAXBuilder builder = new SAXBuilder();
Reader in = new StringReader(xml);
Document doc = null;
Element root = null;
doc = builder.build(in); // this line throws the Exception
看来 JDOM 不喜欢 '&' 或 '=' 字符。如何使用 JDOM 成功解析此 XML?