java - XMLPullParser Unexpected token -


i trying parse xml located on remote server using xmlpullparser on android. following exception thrown:

org.xmlpull.v1.xmlpullparserexception: unexpected token (position:text @1:2 in java.io.inputstreamreader@4113ab20)  

the xml file begins this:

<arrayofmoney xmlns="http://schemas.datacontract.org/2004/07/demo.samples" xmlns:i="http://www.w3.org/2001/xmlschema-instance"> 

and here code using parse it:

defaulthttpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(url); // response httpresponse httpresponse = httpclient.execute(httppost); httpentity httpentity = httpresponse.getentity(); string xmlcontent = entityutils.tostring(httpentity);  // create xmlpullparser instance xmlpullparserfactory factory = xmlpullparserfactory.newinstance(); factory.setnamespaceaware(true); xmlpullparser parser = factory.newpullparser();    parser.setinput(new stringreader(xmlcontent));  int eventtype = parser.geteventtype(); while (eventtype != xmlpullparser.end_document) {     string tagname = parser.getname();     string text = "";     employee employee= null;     switch (eventtype) {     case xmlpullparser.start_tag:         if (tagname.equalsignorecase("employee")) {             // create new instance of employee             employee= new employee();         }         break;      case xmlpullparser.text:         text = parser.gettext();         break;      case xmlpullparser.end_tag:         if (tagname.equalsignorecase("payement")) {             // add employee object list             employeelist.add(employee);         } else if (tagname.equalsignorecase("received")) {             employee.set_code(text);         }          break;      default:         break;     }     eventtype = parser.next(); } 

i tried following answer posted on this question, same error still thrown.

any idea how resolve issue?


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -