Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issues parsing XML

 
G Singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am trying to parse the following xml


My parsing code is


However I get the following error


Does anyone have any suggestions on why its tripping on the "qp" parameter
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's because the XML is malformed. The ampersands (&) in that text node aren't escaped properly.
 
Yves Zoundi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace by . Remove the + there, all together with no space

[ October 30, 2008: Message edited by: Yves Zoundi ]
[ October 30, 2008: Message edited by: Yves Zoundi ]
 
G Singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much for your help, however I don't have control over the XML source, is there any alternatives. (I'm using dom4j to parse)
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by G Singh:
Thanks so much for your help, however I don't have control over the XML source, is there any alternatives. (I'm using dom4j to parse)
So you are downloading this malformed XML from somebody else's site? Then you must call them up and tell them about that. Get them to fix their bad outputs.

There aren't any parsers that will fix up malformed XML. That's because the original XML recommendation basically forbids them from doing that. So it's the responsibility of the people producing an XML document to make sure that it's a well-formed document. Don't let people get away with irresponsible XML.

However in the meantime there's nothing stopping you from using non-XML methods to read that document. You can scan for < followed by an element name, and so on, using ordinary Java I/O and string handling methods. But don't expect any XML parser to handle it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic