Org.xmlpull.v1.XmlPullParserException:Unexpected token

Source: Internet
Author: User

Org.xmlpull.v1.XmlPullParserException:Unexpected token (position:unknown @5:1 in java.io.inputstreamreader@ 3FE1C1A2)
The problem is this, get an XML stream from the server, and then the Android client resolves it, but always package this error.

Pull parser parses XML input stream private Boolean parsexml (InputStream iStream) throws Xmlpullparserexception, I
                oexception {//TODO auto-generated method Stub news = null;
                Parsing Xmlpullparser parser = Xml.newpullparser () with pull parser;
                Parser.setinput (IStream, "utf-8");
                int event = Parser.geteventtype (); while (event!= xmlpullparser.end_document) {switch (event) {case Xmlpullparser. Start_document:if (Newes = = null) {throw new Illegalargumentexceptio

                        N ("Newes parameter cannot be null");
                        } log.i (Tag_service, "Start parsing xml file");
                    Break
                        Case XMLPULLPARSER.START_TAG:LOG.I (Tag_service, "encounter starting Tag" + parser.getname ());
      if ("News1". Equals (Parser.getname ()) {                      String id = parser.getattributetype (0);
                            News = new News ();
                        News.setid (integer.valueof (id)); } if ("Title1". Equals (Parser.getname ())) {News.settitle (Parser.nextte

                        XT ()); } if ("Age1". Equals (Parser.getname ())) {News.setage (integer.valueof p

                        Arser.nexttext ()));
                    } break;
                        Case XMLPULLPARSER.END_TAG:LOG.I (Tag_service, "Encounter end Tag" + parser.getname ());
                            if ("News1". Equals (Parser.getname ())) {Newes.add (news);

                        News = null;
                    } break;
                    Default:break; event = Parser.next();
            return true; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.