Search code examples
androidxmlsax

XML parse error on ë (crash with accented letters)


I have a crash in an xml file. it occurs on a ë, in this case belgië (dutch for belgium).

I'm busy with searching for an answer but I just can't find a solution.

I'm using the sax parser under Android. error: org.apache.harmony.xml.ExpatParser$ParseException: At line 2, column 204: not well-formed xml source: http://biohorma.weatheronyoursite.com/villadm_hooikoortsverwachting_be.xml

Side note, i get the data via a stream, is the only option to put this stream to a temp value, replace the illegal character with a valid one and make a new stream of it or can you add something in the stream to do this?


Solution

  • It seems you should use the String (byte[] bytes, String enc) constructor, assuming what server sends you is encoded in UTF-8:

    String properXml = new String(byteArrayIReceivedFromServer, "UTF-8");