1

While I am processing XML file, the Stax parser encountered the following line:

<node id="281224530" lat="48.8975614" lon="8.7055191" version="8" timestamp="2015-06-07T22:47:39Z" changeset="31801740" uid="272351" user="Krte�?ek">

and as you see there is a strange character at the end of the line, and when the parser reaches that line the program stops and gives me the following error:

Exception in thread "main" javax.xml.stream.XMLStreamException: ParseError  
at [row,col]:[338019,145]

Message: Ungültiges Byte 2 von 2-Byte-UTF-8-Sequenz.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown 
Source)
at com.example.Main.main(Main.java:46)

Is there any thing I should change in the settings of Eclipse to avoid that error?

Update

code:

XMLInputFactory factory = XMLInputFactory.newInstance();
        XMLStreamReader parser = null;
        try {
            parser = factory.createXMLStreamReader(in);
        } catch (XMLStreamException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.d(TAG, "newParser",
                    "e/createXMLStreamReader: " + e.getMessage());
        }
Jiri Tousek
  • 12,211
  • 5
  • 29
  • 43
Amrmsmb
  • 1
  • 27
  • 104
  • 226

2 Answers2

1

It is not about eclipse, but it is about encoding of your file. There are two cases:

1) file is corrupted, i.e. it contains incorrect symbols, not from defined encoding

2) file is not in utf-8 encoding and it is defined in xml header. So you should check, that you are reading file contents appropriately.

Andremoniy
  • 34,031
  • 20
  • 135
  • 241
0

If you edited and saved your XML file in eclipse, this can be a problem in case your eclipse is not configured to use UTF-8. Check this question: How to support UTF-8 encoding in Eclipse

Otherwise you probably don't need to do anything about your code. You just need a correctly UTF-8-encoded content.

Community
  • 1
  • 1
nolexa
  • 2,392
  • 2
  • 19
  • 19