7
我正在開發android上的應用程序!在Android中使用XPath搜索XML文件
那麼我現在有一點衝突,我想執行一個XPath查詢,但我沒有到達解決這個問題。
這XML filethat我用一個例子:
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England.</description>
</book>
</catalog>
我該怎麼辦?
在此先感謝!
+1只是爲了被別人誰記得,顯示所導入的命名空間! – SteveCav 2012-02-01 01:48:05
如果我在線託管XML,我可以解析它,我應該讀取它全部 – AMH 2012-07-29 00:13:42
要讀取外部XML文件,可以使用URL類使用SAX打開流。用此行代替NodeList實例化NodeList shows =(NodeList)xPath.evaluate(「/ schedule/show」,new InputSource(new URL( 「http://www.exple.com/file.xml").openStream ()),XPathConstants.NODESET);' – alibenmessaoud 2012-07-29 10:47:05