views:

308

answers:

1

i need to parse this php xml response in android:

<?phpxml version="1.0" encoding="utf-8"?> 

<SmsResponse>

<version>1</version>    
<result>0</result> 
<resultstring>failure</resultstring> 
<description>error</description>    
<endcause></endcause>
</SmsResponse>
A: 

that error comes from the C expat XML parsing library, and it's telling you that XML files need to start "<?xml". if the server sending the bad response is yours, fix the server. if it isn't, you'll have to do something like responseString.replaceFirst("^<\\?phpxml", "<?xml") to fix it before handing it over to the XML parser.

this isn't Android-specific. all XML parsers should reject this invalid input.

Elliott Hughes