• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issues parsing XML

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's because the XML is malformed. The ampersands (&) in that text node aren't escaped properly.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic