使用 Python 在 Appengine 中解析 xml 的最佳方法
我正在连接到 isbndb.com 获取书籍信息,他们的响应如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<ISBNdb server_time="2005-02-25T23:03:41">
<BookList total_results="1" page_size="10" page_number="1" shown_results="1">
<BookData book_id="somebook" isbn="0123456789">
<Title>Interesting Book</Title>
<TitleLong>Interesting Book: Read it or else..</TitleLong>
<AuthorsText>John Doe</AuthorsText>
<PublisherText>Acme Publishing</PublisherText>
</BookData>
</BookList>
</ISBNdb>
What is the best way to put this data into an object using appengine (Python)?
我需要 isbn 编号(BookData 中的标签),但我还需要 BookData 所有子项的内容(而不是标签)。
I am connecting to isbndb.com for book information and their response looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ISBNdb server_time="2005-02-25T23:03:41">
<BookList total_results="1" page_size="10" page_number="1" shown_results="1">
<BookData book_id="somebook" isbn="0123456789">
<Title>Interesting Book</Title>
<TitleLong>Interesting Book: Read it or else..</TitleLong>
<AuthorsText>John Doe</AuthorsText>
<PublisherText>Acme Publishing</PublisherText>
</BookData>
</BookList>
</ISBNdb>
What is the best way to turn this data into an object using appengine (Python)?
I need the isbn number (a tag in BookData) but I also need the contents (as opposed to tags) of all the children of BookData.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 etree:)
use etree:)
有一个优秀的 Python 模块,名为 BeautifulSoup。使用 BeautifulStoneSoup 类进行 XML 解析。
更多信息:http://www.crummy.com/software/BeautifulSoup/documentation.html< /a>
There is an excellent Python module called BeautifulSoup. Use the BeautifulStoneSoup class for XML parsing.
More info: http://www.crummy.com/software/BeautifulSoup/documentation.html