首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >提取Java中的XML属性(ISBNDB)

提取Java中的XML属性(ISBNDB)
EN

Stack Overflow用户
提问于 2012-04-09 12:11:25
回答 1查看 299关注 0票数 0

因此,我正在编写一个android应用程序,它需要从网络上获取图书价格数据。我找到了isbndb.com,它似乎提供了很好的资源和价格比较。唯一的问题是他们的xml文件有点复杂。

我是用Java解析XML的新手,对此了解不多。我知道如何解析基本的xml文件。使用简单的标签。我通常使用DocumentBuilder和DocumentBuilderFactory,但是这是我试图解析的文件的一部分。

代码语言:javascript
复制
<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。如果有人能帮我这个忙,我将不胜感激。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-09 12:32:57

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

代码语言:javascript
复制
    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")方法来解析属性值。希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10068805

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档