[英]Resource XML for validation and parsing
I have an XML file in the res/xml folder which I want to parse using getXML()
. 我要使用getXML()
解析的res / xml文件夹中有一个XML文件。
But I also want to validate it first against an XSD schema. 但我也想首先针对XSD架构对其进行验证。
How can I create a InputStreamReader for the XML file for validation? 如何为XML文件创建InputStreamReader以进行验证?
It turns out that to use openRawResource()
the file should be under res/raw or in assets 事实证明,要使用openRawResource()
,文件应位于res / raw下或资产中
read it from the classpath, getclass -> getresourceasstream. 从类路径读取它,getclass-> getresourceasstream。 For validation consider using the xerces lib. 为了进行验证,请考虑使用xerces库。
Put it under \\res\\xml\\ folder. 将其放在\\ res \\ xml \\文件夹下。 Then you can open it with: 然后,您可以使用以下命令打开它:
Resources res = activity.getResources();
XmlResourceParser xrp = res.getXml(R.xml.your_resId);
Please follow below link for XMLResourceParser 请点击以下XMLResourceParser链接
http://android-er.blogspot.com/2010/04/read-xml-resources-in-android-using.html http://android-er.blogspot.com/2010/04/read-xml-resources-in-android-using.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.