• 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

An invalid XML character Unicode: 0x19

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I keep getting an xml error when I pass a string read from a database (that happens to be formatted xml) into the my parser created with:


The error states that it encountered the character 0x19 which it could not handle. Problem is, I can't find this character anywhere within the string that I pass into the parser!

Doing a check with this code finds nothing:


Can anyone suggest a solution? I simply want to strip out any illegal XML charaters (less that 0x20 etc) and replace them with nothing but I can't even find the position within the string that they occur.

Cheers, Jared.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isn't that a <ctrl>Z character as typically used as a end-of-file or end-of-input mark? I think I would try the .trim() function on the String.
Bill
 
Jared Cope
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip. No luck unfortunately. I did revise my checking loop to this though:



I get output such as:



But my 'newString' variable still chokes up xerces, complaining about unicode 0x13 characters. I just don't know how they are slipping through.

Cheers, Jared.
 
Jared Cope
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

For anyone that is interested in this problem, I have been having a bit of success with the org.apache.commons.lang package and the StringEscapeUtils.escapeXml() method.

In addition to converting XML specific characters like '&' and '<' to their escaped representation, the method seems to be culling any other illegal characters from the text.

Cheers, Jared.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip - it always good to hear what works!
Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic