read it from the classpath, getclass -> getresourceasstream. For validation consider using the xerces lib.
Resource XML for validation and parsing
-
19-10-2022 - |
سؤال
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
المحلول
نصائح أخرى
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
لا تنتمي إلى StackOverflow