• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Error parsing special characters

 
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to parse a xml file that contains the following string.
Cr�ditos Ajustes & Otros Cargos.
but the parser doesn't recognize this characters. I am using the correct encoding 'iso-8859-1'. It gives me this error

loadDOM threw org.xml.sax.SAXParseException: Illegal character or entity reference syntax.

org.xml.sax.SAXParseException: Illegal character or entity reference syntax.

at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)

at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3170)

at org.apache.crimson.parser.Parser2.maybeReferenceInContent(Parser2.java:2420)

at org.apache.crimson.parser.Parser2.content(Parser2.java:1833)

at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)

at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)

at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)

at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)

at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)

at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)

at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)

at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:151)

at com.cingular.olam.tlgpreprocessor.spanish.spanishParser.parse(spanishParser.java:89)java.lang.NullPointerException

at com.cingular.olam.tlgpreprocessor.spanish.spanishParser.parse(spanishParser.java:105)

at com.cingular.olam.tlgpreprocessor.spanish.spanishBill.create(spanishBill.java:33)

at com.cingular.olam.tlgpreprocessor.spanish.spanishBill.create(spanishBill.java:33)

at com.cingular.olam.tlgpreprocessor.spanish.spanishTest.main(spanishTest.java:35)



at com.cingular.olam.tlgpreprocessor.spanish.spanishTest.main(spanishTest.java:35)

Exception in thread "main"
Can you guys help me out here.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ampersand in the middle of your string is an illegal character in XML. You need to encode it with "&" or the equivalent numerical character reference.
 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not the issue. Actually when I am trying to parse.
Cr�ditos, Ajustes y Otros Cargos.
I can successfully parse and write it out to a file on windows machine.
But on unix, when I parse and print it out to a file, it gets converted to a Cr?ditos, Ajustes y Otros Cargos.
It is generating a question mark on Unix for special characters. Do you guys know the reason why it is happening.
 
His brain is the size of a cherry pit! About the size of this ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic