<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>
[xmlpull]XmlPull常见错误
编写者
|
日期
|
关键词
|
郑昀@ultrapower
|
2005-9-28
|
Xmlpull kxml java
|
Xmlpull官方站点:http://www.xmlpull.org/
优点:不必等整个文档解析完成,部分求值结果早就可以开始反馈给用户。
What Is It?
XmlPull project is dedicated to be a site for
- for general Pull parsing promotion/education (including StAX) and in particular to contain easy-to-reuse samples and code fragments
- a resource for discussing new ideas and concepts related to pull parsing
- a java namespace (org.xmlpull.*) and project location of a free implementation of the event object API and Factories, based on the StAX XMLStreamReade and old Common API for XML Pull Parsing
- as java namespace and project location of StAX and XmlPull based utilities and samples such as:
- providing an XML stream from a DOM tree
- a DOM builder
- SAX adapter
- JUnit tests
- as a maintenance resource for the existing XmlPull interface
常见错误一:XmlPullParserException:resource not found
网络中有很多人问到同样一个问题:
为什么我们在调用
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
时,总是得到这样的错误:
错误提示:
|
Exception in thread "main" org.xmlpull.v1.XmlPullParserException: caused by: org.xmlpull.v1.XmlPullParserException: resource not found: /META-INF/services/org.xmlpull.v1.XmlPullParserFactory make sure that parser implementing XmlPull API is available
at org.xmlpull.v1.XmlPullParserFactory.newInstance(XmlPullParserFactory.java:294)
|
虽然从http://www.xmlpull.org/v1/doc/api/org/xmlpull/v1/XmlPullParserFactory.html
看到了他们自己的注解:
XmlPullParserFactory的注释:
|
If no name of parser factory was passed (or is null) it will try to find name by searching in CLASSPATH for META-INF/services/org.xmlpull.v1.XmlPullParserFactory resource that should contain a comma separated list of class names of factories or parsers to try (in order from left to the right). If none found, it will throw an exception. NOTE:In J2SE or J2EE environments, you may want to use newInstance(property, classLoaderCtx) where first argument is System.getProperty(XmlPullParserFactory.PROPERTY_NAME) and second is Thread.getContextClassLoader().getClass() .
|
看来它确实需要寻找这么一个资源:
META-INF/services/org.xmlpull.v1.XmlPullParserFactory
。但又没说如何才能找到它。
解决办法
将http://kxml.sourceforge.net/
下载的kxml2.jar加到你的项目中即可。这时候再调用
XmlPullParserFactory factory = XmlPullParserFactory.newInstance(
System.getProperty(XmlPullParserFactory.PROPERTY_NAME),
Thread.currentThread().getContextClassLoader().getClass() );
就通过了。
kxml2.jar就包含了META-INF/services/org.xmlpull.v1.XmlPullParserFactory文件,它的内容其实就是一句话:
org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer
编写者
|
日期
|
关键词
|
郑昀@ultrapower
|
2005-9-28
|
Xmlpull kxml java
|
分享到:
相关推荐
工具包包括了:xmlpull_1_1_3_4c.jar;xmlpull_1.1.3.1.jar等。可以解析xml,导入时请将xmlpull_1_1_3_4c.jar;xmlpull_1.1.3.1.jar都导入,不然会报错。
在java平台上XmlPull的jar包(kxml2-2.3.0.jar,xmlpull-1.1.3.1.jar)
XStream报错 org/xmlpull/v1/XmlPullParserException org.xmlpull.v1.XmlPullParserException
pull方式xml解析jar包,xmlpull-1.1.3.1.jar和xmlpull-1.1.3.1.jar
XMLpull解析时用到的JAR包,你肯定用得到,对于三种XML解析来说,Pull解析是最适合Android开发的。
Xmlpull 源代码 Xmlpull 源代码 Xmlpull 源代码
xmlpull-1.1.3.1.jar和kxml2-2.3.0.jar。支持XMLPULL解析的两个必备JAR包。作者亲测!ok
The type org.xmlpull.v1.XmlPullParser cannot be resolved. It is indirectly referenced from required .class files报错时导入xmlpull_1_0_5.jar
XMLPullProject(XMLPull读取) 非常不错的源代码,有利于初学者的学习
xmlpull xml解析技术 含jar包
这是xmlpull的测试版本,废了好长时间才找到的,如果想要下载更多版本,可以去xmlpull的官网山去下载,不嫌弃的话拿去用吧
对xml文件进行xmlpull解析 所需要的jar包对xml文件进行xmlpull解析 所需要的jar包对xml文件进行xmlpull解析 所需要的jar包
xstream-1.4.9.jar,xmlpull-1.1.3.1.jar,xstream-benchmark-1.4.9.jar,xstream-jmh-1.4.9.jar,dom4j-1.6.1.jar,slf4j-api-1.6.1.jar等
java_pull解析器使用包kxml2_xmlpull,包括gson-2.8.2.jar;kxml2-2.3.0.jar;xmlpull_1_1_3_4c.jar;xmlpull-1.1.3.1,jar;xstream-1.4.10.jar
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; public class SimpleXmlPullApp { public static void main (String ...
完整的xstream+xmlpull jar包
xml解析+kxml2+xmlpull.......................................................
Xml解析中的一种Pull解析,可以学习下。
在android开发中经常会使用到xml文件,用来保存和传递数据,因此解析xml就是需要掌握的技能了,pull解析器是android自带的解析工具