在Java中提取XML属性(ISBNDB)

在Java中提取XML属性(ISBNDB),java,android,xml,parsing,Java,Android,Xml,Parsing,因此,我正在编写一个android应用程序,需要从网络上获取图书价格数据。我发现isbndb.com似乎提供了很好的资源和价格比较。唯一的问题是他们的xml文件有点复杂 我不熟悉用Java解析XML,但知道的不多。我知道如何解析基本的xml文件。使用简单的标签。我通常使用DocumentBuilder和DocumentBuilderFactory,但这是我试图解析的文件的一部分 <Prices price_time="2012-04-08T20:05:49Z"> <Price

因此,我正在编写一个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。如果有人能帮我,我会非常感激


谢谢

您可以使用上面提到的解析xml和检索可以使用的属性值

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

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




}

getValue(“store_title”)方法将用于解析属性值。希望能有所帮助。

你试过什么吗?我完成了一个类似的教程,我了解它是如何工作的。但是,该示例不包括我试图解析的任何属性标记。