0

だから私は、Web から書籍の価格データを取得する必要がある Android アプリを作成しています。優れたリソースと価格比較を提供しているように見える isbndb.com を見つけました。唯一の問題は、それらの xml ファイルが少し複雑であることです。

私はJavaでXMLを解析するのが初めてで、あまり知りません。基本的な xml ファイルを解析する方法を知っています。シンプルなタグ付き。私は通常 DocumentBuilder と DocumentBuilderFactory を使用しますが、これは解析しようとしているファイルの一部です。

<Prices price_time="2012-04-08T20:05:49Z">
<Price store_isbn="" store_title="Discworld: Thief of Time" store_url="http://isbndb.com/x/book/thief_of_time/buy/isbn/ebay.html" store_id="ebay" currency_code="USD" is_in_stock="1" is_historic="0" check_time="2008-12-09T12:00:51Z" is_new="0" currency_rate="1" price="0.99"/>
<Price store_isbn="" store_title="" store_url="http://bookshop.blackwell.com/bobus/scripts/home.jsp?action=search&type=isbn&term=0061031321&source=1154376025" store_id="blackwell" currency_code="USD" is_in_stock="0" is_historic="0" is_new="1" check_time="2011-11-08T02:54:15Z" currency_rate="1" price="7.99"/> 
</Prices> 

私がやろうとしているのは、store_isbn や store_title などの属性値で情報を取得することです。誰かがこれで私を助けることができれば、私は本当に感謝しています.

ありがとう

4

1 に答える 1

1

上記のリンクを使用してxmlを解析し、属性値を取得するには、以下を使用できます。

    public void startElement(String uri, String localName,String qName, 
            Attributes attributes) throws SAXException {

    System.out.println("Start Element :" + attributes.getValue("store_title"));




}

attributes.getValue("store_title") メソッドは、属性値の解析に使用されます。それが役立つことを願っています。

于 2012-04-09T04:32:57.467 に答える