Invalid character '&#x0' encountered

iOSDev picture iOSDev · Jun 9, 2009 · Viewed 23.6k times · Source

I am getting following exception while parsing the xml.

Fatal error at line -1  Invalid character '&#x0' encountered. No stack trace

I have Xml data in string format and I am parsing it using DOM parser. I am parsing data which is a response from Java server to a Blackberry client. I also tried parsing with SAX parser,but problem is not resolved. Please help.

Answer

Thorbjørn Ravn Andersen picture Thorbjørn Ravn Andersen · Jun 9, 2009

You have a null character in your character stream, i.e. char(0) which is not valid in an XML-document. If this is not present in the original string, then it is most likely a character decoding issue.