This was the culprit:
To have the system accept the URL, I'm changing the
&
character in the URL parameter to be&
;
For some reason the system wasn't accepting a URL without that change, but it seems to be fine now.
题
I'm writing an Android application that parses an XML feed using XmlPullParser.
This is the XML I'm attempting to parse:
This is the code where it's blowing up:
public List parseRouteInfo(InputStream in) throws XmlPullParserException, IOException {
try {
XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(in, null);
// This is the line
parser.nextTag();
parser.require(XmlPullParser.START_TAG, ns, "RoutePattern");
return readPatterns(parser);
} finally {
in.close();
}
}
And this is the exception thrown:
org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@416d80a8)
To have the system accept the URL, I'm changing the &
character in the URL parameter to be &
but aside from that I'm following the Android XML Parsing Tutorial as closely as possible.
I understand why an exception is thrown (no START_TAG
or END_TAG
found), but I can't figure out why the parser is at END_DOCUMENT
.
解决方案
This was the culprit:
To have the system accept the URL, I'm changing the
&
character in the URL parameter to be&
;
For some reason the system wasn't accepting a URL without that change, but it seems to be fine now.