Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    95
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Getting "PI must not start with xml"-error

    Hi
    I have the following code:
    Code:
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    list.add(new BasicNameValuePair("a", "Get"));    
    
    	            MyHandler handler = new MyHandler();
    	            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    	            factory.setNamespaceAware(true);
    	            XmlPullParser parser = factory.newPullParser(); 
    	            parser.setInput(new InputStreamReader(handler.getData(list), "UTF-8"));  
    	            List<DataListItem> spinnerList = new ArrayList<DataListItem>();
    	            parser.next();
    	            
    	            while (parser.getEventType() != XmlPullParser.END_DOCUMENT)
    	            {
    	            	if (parser.getEventType() == XmlPullParser.START_TAG && parser.getName().equals("area"))
    	            		spinnerList.add(new DataListItem(parser.getAttributeValue(0) + " (" + parser.getAttributeValue(1) + ")", parser.getAttributeValue(2)));
    	            	parser.next();
    	            }
    but I get the following error:
    "PI must not start with xml"

    My xml file looks like this:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <country>
      <area
        name="Ackidacke"
        id="10"
        nr="1"/>
    </country>
    How do I solve this?

    It seems the error occurs when there is a whitespace/newline before "<?xml version="1.0" encoding="utf-8"?>"-declaration, but I can´t seem to find anyone.
    Last edited by earni23; 01-18-2011 at 10:29 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •