php xml response gave me this after android sax parsing: XML or text declaration not at start of entity
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&g开发者_如何转开发t;failure</resultstring>
<description>error</description>
<endcause></endcause>
</SmsResponse>
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.
精彩评论