Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 68
Registered: ‎10-26-2008
My Device: Not Specified

Re: SAXParseException: Expecting an element

Is there a service online where I can check my XML?  I plugged it into a few pages already and it is a well-formed XML file...shouldn't there checkers catch the null char?
Developer
Posts: 33
Registered: ‎07-16-2008
My Device: Not Specified

Re: SAXParseException: Expecting an element

I had the same problem with character '&#x0' and in my case the solution was the following

// lets assume we have filled xml-bytes from a httpconnection // to the byte[] which we call xmlBytes String xmlAsString = new String(xmlBytes, "UTF-8"); xmlAsString = StringUtilities.removeChars(xmlAsString, "\u0000"); xmlBytes = xmlAsString.getBytes(); // now we can parse without the error // "Invalid character '&#x0' encountered" ByteArrayInputStream _bis = new ByteArrayInputStream(xmlBytes); Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(_bis); Element el = d.getDocumentElement(); el.normalize();

 

Regards Anil
Developer
Posts: 38
Registered: ‎06-03-2009
My Device: 9800
My Carrier: Verizone

Re: SAXParseException: Expecting an element

Greate ..

 

I was also having the same issue !! thanks