I do not get errors on Android 3.0+, but only on Android 2.2, 2.3.3, when I try to parse a small XML file through XmlPullParser , the application breaks with an error:
org.xmlpull.v1.XmlPullParserException: PI must not start with xml (position:unknown @1:5 in java.io.InputStreamReader@40568770 )
What is the PI mentioned in the error ???
I found out that this can lead to the first line of the XML file ( <?xml version="1.0" encoding="utf-8"?> ), But I have not found a reason why this happens on lower versions of Android.
If this is the cause of the error (first line of the XML file), how can I fix this?
Should I:
a) ask the web server administrator to change the XML? If so, what should it change in XML?
b) substring of InputStream using BufferedReader ?
Somehow I think that the second approach will cause additional delays on weak Android phones.
EDIT
I pulled the XML content from the debugger and saw that the first seems to end with \r\n , then the following characters are triggered. Does this tell you something?
And this is what the XML file looks like. It is small and there is no obvious reason why the application crashes.
<?xml version="1.0" encoding="utf-8"?> <song> <artist>Pink Floyd</artist> <title>Shine On You Crazy Diamond</title> <picture>http://www.xxyz.com/images/image.jpg</picture> <time>Fri, 23 Nov 2012 11:22:31 GMT</time> </song>
This is how an InputStream taken from this XML looks like (only leading characters).

Please advise!!!
source share