문제

I have an XML file in the res/xml folder which I want to parse using getXML().

But I also want to validate it first against an XSD schema.

How can I create a InputStreamReader for the XML file for validation?
It turns out that to use openRawResource() the file should be under res/raw or in assets

도움이 되었습니까?

해결책

read it from the classpath, getclass -> getresourceasstream. For validation consider using the xerces lib.

다른 팁

Put it under \res\xml\ folder. Then you can open it with:

 Resources res = activity.getResources();
 XmlResourceParser xrp = res.getXml(R.xml.your_resId);

Please follow below link for XMLResourceParser

http://android-er.blogspot.com/2010/04/read-xml-resources-in-android-using.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top