简体   繁体   中英

Android SAXParser Malformed XMl error

I have a server component which uses SAXParser (javax.xml.parsers.SAXParserFactory) to parse an XML. I am reusing this library in my phonegap app for android. The problem is that when I use the library to communicate to the server and parse the response from the server, it fails with - Malformed XML - exception. However, if I use the same library from normal Java program, the response from the server is processed fine by the parser and there is no error. I compared the XML payloads in both android and normal javacase and they are exactly the same. I know that this is a very vague and strange question with very little to go on but I am out of ideas. Any ideas or hints would be helpful.

Is there a DTD or namespace in that XML? It may be possible that the android app has a problem with those and fail to parse because of that. (Is there an exact error message?)

You may check what are the differences between the parsers by checking

There might be a difference. If there is, use SAXParserFactory#setNamespaceAware() and SAXParserFactory#setValidating() to set the same values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM