日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[xmlpull]XmlPull常见错误

發布時間:2025/3/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [xmlpull]XmlPull常见错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

[xmlpull]XmlPull常見錯誤

編寫者<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

日期

關鍵詞

鄭昀@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]XmlPull常见错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。