1

My code is something like

public void parse(String input) throws XmlPullParserException, IOException {
    InputStream is = null;
    try {
        is = new ByteArrayInputStream(input.getBytes("Big-5"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    XmlPullParser parser = Xml.newPullParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,false);

    parser.setInput(is,"Big-5");
    readFeed(parser);
}
private void readFeed(XmlPullParser parser) throws XmlPullParserException, IOException {
    int eventType = parser.getEventType();
    while(eventType!=parser.END_DOCUMENT){
        String text = parser.getName();

        Log.d(TAG,"text:"+text);

        eventType=parser.nextTag();
    }
}

and there is error in logcat

01-20 18:41:34.361  17574-17574/global.fantasyfighter.hongkongnews W/System.errīš• org.xmlpull.v1.XmlPullParserException: expected: /SCRIPT read: script (position:END_TAG </script>@23:10 in java.io.InputStreamReader@428c5000)

The first few lines of the Xml:

    <meta http-equiv="refresh" content="900" />
<link rel="image_src" href="http://www.hkheadline.com/images/headline_logo_2_2_line_small.jpg">
<SCRIPT LANGUAGE="JavaScript">
<!-- somefunction omitted by author-->
</script>

From this error I knew that it is because XmlPullParser find <SCRIPT> and expect </SCRIPT> found in the xml, but instead </script> is found. The problem is I cannot make the XmlPullParser not case sensitive to the tag during parsing. And the XmlPullParserException is keeping thrown in my apps.

KCC
  • 128
  • 2
  • 7

1 Answers1

0

How about this?

if (tagname.equalsIgnoreCase("script"))
 {
   Code here...
  }

equalsIgnoreCase :

Compares this String to another String, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case.

user3289108
  • 770
  • 5
  • 10
  • 29