I get no error on Android 3.0+, but only on Android 2.2, 2.3.3 when I try to parse a small XML file via XmlPullParser
, the app 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 PI mentioned in the error???
I found out that this may cause the first line of XML file (<?xml version="1.0" encoding="utf-8"?>
), but I did not find the reason why this is happening on lower Android versions.
If this is the cause of error (first line of XML file), how can I fix this?
Should I:
a) ask the admin of web server to change XML? If yes, what he should change in XML?
b) substring InputStream
using BufferedReader
?
Somehow I think that the 2nd approach will cause extra delays on weak Android phones.
EDIT
I pulled XML content from debugger and saw that the first like is ending with \r\n
, then the next characters starts. Does this say anything to you?
And this is how XML file look like. It's a small one and there is no visual reason why app is crashing.
<?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 InputStream taken from this XML look like (starting chars only).
Please advise!!!