Android : Reading XML from local resource (for testing)

后端 未结 3 791
面向向阳花
面向向阳花 2020-12-06 07:08

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.

Unfortu

3条回答
  •  误落风尘
    2020-12-06 07:49

    Create a raw folder under res

    Put your XML file in there, eg. testXML.xml:

    /res/raw/testXML.xml

    You should be able to use your XML parser using that as an inputstream:

    Xml.parse(getResources().openRawResource(R.raw.testXML), Xml.Encoding.UTF_8, root.getContentHandler());
    

    Try that.

提交回复
热议问题