File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Issues parsing XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Issues parsing XML" Watch "Issues parsing XML" New topic
Author

Issues parsing XML

G Singh
Greenhorn

Joined: Oct 29, 2008
Posts: 6
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
Bartender

Joined: Oct 14, 2005
Posts: 18564
    
    8

It's because the XML is malformed. The ampersands (&) in that text node aren't escaped properly.
Yves Zoundi
Ranch Hand

Joined: Aug 31, 2008
Posts: 47
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 ]

Author of VFSJFileChooser and XPontus XML Editor
G Singh
Greenhorn

Joined: Oct 29, 2008
Posts: 6
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
Bartender

Joined: Oct 14, 2005
Posts: 18564
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issues parsing XML