9

SO,

I am building XML string based on the values from the dataset using XMLWriter.

It is properly building the xml string as per the settings and the conditions I specified.

If there are more than 1000 records in the dataset and when I try to build the xml string I am getting the above error. hexadecimal 0X19 is an invalid character

How do I get pass this. I have spent around 6 hrs trying to figure out.

Please help

1

4 Answers 4

15

Quite simply, you're not allowed that character in an XML document, no matter how you mark it up. To quote the spec:

Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

Roughly translated, that means that before 0x20, you're only allowed tab (0x09), newline (0x0a) and carriage return (0x0d).

The normal way to overcome this sort of issue to use another, embedded, encoding like base64.

2

Hex 0x19 is a control code in the ASCII sequence - it is End of Medium (EM). I'm not sure how it is getting into your data stream. If you are encoding something requiring more than one byte into UTF-8 and then treating it as a single byte character set or some other similar encode/decode sequence, you could be seeing the second byte of a UTF-8 sequence.

Are you transcoding from one character set to another? and What are the input and output encodings?

1
  • 3
    You can get those values if you copy and paste a Microsoft Word document with smart quotes turned on. Our Oracle database is US7ASCII, so perhaps the unicode is stored but only the last two characters are saved? These "smart" single quote and "smart" double characters are being stored as hex 18, 19, 1C, 1D: stackoverflow.com/questions/2826191/… Proof: i.imgur.com/hVpv7NB.jpg
    – Sun
    Mar 2, 2016 at 19:30
-1

try 0x19 instead :)

hexadecimal (base 16) uses 16 symbols which are 0 to 9 and A B C D E F (or a to f, which represents 10 to 15)

0x is just a prefix for numeric constants in programming languages (like C) and shells

0
-1

I've seen similar errors occur with invalid characters in XML tag and/or attribute names. For example, if you don't include a space when manually building up the xml,

 <tagNameattributeName="attributeValue">

would throw an error vs the intended

 <tagName attributeName="attributeValue">

Might be worth a look.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.