• 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

parsing XML entity reference in Java

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
My java program parses an XML document with the following line:

<ORGS>
<ORG1 SID="1" BN="101" DESC="US OPERATIONS" />
<ORG2 SID="2" BN="102" DESC="CANADA UNIT" />
<ORG3 SID="3" BN="103" DESC="'SA' <BA> & "MEXICO"" />
</ORGS>

And should display a report like:
SID BN DESC
----------------
1 101 US OPERATIONS
2 102 CANADA UNIT
3 103 'SA' <BA> & "MEXICO"

But upon parsing, I get an error like:

org.xml.sax.SAXParseException: Attribute names must not start with "'" characters.

It seems like the entity references are not parsed properly.. any idea? solution? help?

Thanks..
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try replacing "MEXICO" with MEXICO.

P.
 
lyko saha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, but it doesn't work..
Actually, I have a problem with the XML parser..
I am using the DocumentBuilder's parse method - which does not work on my program properly...
 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lyko Saha,
I want to help you...
I think you should replace some escape characters on your xml like this




Correct me if i am wrong
hope this help
daniel
[ November 09, 2004: Message edited by: Fisher Daniel ]
 
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic