Alex Rivera | Logout

Android : Reading XML from local resource (for testing)

Asked 2011-02-24T23:13:06.947
9

I'm writing an app which will read XML from a webservice (probably via kSOAP2). I'm fairly happy with SAX parsing, as I've done XML parsing iPhone apps.

Unfortunately the webservice isn't public yet so for initial testing I have some files containing the XML I need to parse. In this early dev phase I just need to read the XML from the files and pass it into the XML parser

Xml.parse(this.testXML, root.getContentHandler());

How do I read the XML from a file/resource into a string to pass into this method. I want to crack on and test the parser, but this simple step is holding me up.

Thanks

Edit
Report

1 Answer

-1

Raises exception due to incorrectly formed XML (line1,Pos0).

You tell parser that the encoding is UTF-8 and if it isn't you may get various errors (depending on parsers). If you are using non-xml editor to edit your XML it may save the file in a different encoding regardless what you declared it to be in the XML document.

answered 2013-02-05T13:14:32.213

Your Answer