문제

I'm trying to parse the following XML using JDOM:

<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>

My issue is the line containing "src=1&rate=1&ref=http%3A%2F" appears to cause the following exception:

Caused by: org.xml.sax.SAXParseException: The reference to entity "rate" must end with the ';' delimiter.

Here is the code:

SAXBuilder builder = new SAXBuilder();
Reader in = new StringReader(xml);
Document doc = null;
Element root = null;
doc = builder.build(in); // this line throws the Exception

It appears JDOM doesn't like the '&' or '=' character. How can I use JDOM to successfully parse this XML?

도움이 되었습니까?

해결책

In XML strings, the & character must use the &amp; entity.

Your string should be:

"http://xxx.xxx.xx.xxx:89/broadwave.mp3?src=1&amp;rate=1&amp;ref=http%3A%2F%2F111.92.240.134%3A89%2F"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top