导入
深入探究
了解 Atom 格式聚合源的结构与用途
本书几乎每一章都围绕一段示例代码展开。但XML并不关注代码,而是关注数据。XML的一个常见用途是“聚合源”(syndication feeds),用于列出博客、论坛或其他频繁更新的网站上的最新文章。大多数流行的博客软件都可以生成此类源,并在发布新文章、讨论主题或博文时自动更新。你可以通过“订阅”某个博客的源来关注它,也可以使用专门的“聚合器”同时跟踪多个博客,例如 Google Reader。
本章我们将处理的XML数据就是这样一个源——具体来说,是一个Atom格式的聚合源。
1<?xml version='1.0' encoding='utf-8'?> 2<feed xmlns='http://www.w3.org/2005/Atom' xml:lang='en'> 3 <title>dive into mark</title> 4 <subtitle>目前正处于各种瘾之间</subtitle> 5 <id>tag:diveintomark.org,2001-07-29:/</id> 6 <updated>2009-03-27T21:56:07Z</updated> 7 <link rel='alternate' type='text/html' href='http://diveintomark.org/'/> 8 <entry> 9 <author> 10 <name>Mark</name> 11 <uri>http://diveintomark.org/</uri> 12 </author> 13 <title>Dive into history, 2009 edition</title> 14 <link rel='alternate' type='text/html' 15 href='http://diveintomark.org/archives/2009/03/27/dive-into-history-2009-edition'/> 16 <id>tag:diveintomark.org,2009-03-27:/archives/20090327172042</id> 17 <updated>2009-03-27T21:56:07Z</updated> 18 <published>2009-03-27T17:20:42Z</published> 19 <category scheme='http://diveintomark.org' term='diveintopython'/> 20 <category scheme='http://diveintomark.org' term='docbook'/> 21 <category scheme='http://diveintomark.org' term='html'/> 22 <summary type='html'>将一整章内容放在一页上听起来很臃肿,但请考虑一下——我迄今为止最长的一章有75页印刷版,却能在不到5秒内加载完成……甚至在拨号上网的情况下。</summary> 23 </entry> 24 <entry> 25 <author> 26 <name>Mark</name> 27 <uri>http://diveintomark.org/</uri> 28 </author> 29 <title>Accessibility is a harsh mistress</title> 30 <link rel='alternate' type='text/html' 31 href='http://diveintomark.org/archives/2009/03/21/accessibility-is-a-harsh-mistress'/> 32 <id>tag:diveintomark.org,2009-03-21:/archives/20090321200928</id> 33 <updated>2009-03-22T01:05:37Z</updated> 34 <published>2009-03-21T20:09:28Z</published> 35 <category scheme='http://diveintomark.org' term='accessibility'/> 36 <summary type='html'>无障碍设计的教条不允许人们质疑那些极少有用且极少使用的功能的价值。</summary> 37 </entry> 38 <entry> 39 <author> 40 <name>Mark</name> 41 </author> 42 <title>A gentle introduction to video encoding, part 1: container formats</title> 43 <link rel='alternate' type='text/html' 44 href='http://diveintomark.org/archives/2008/12/18/give-part-1-container-formats'/> 45 <id>tag:diveintomark.org,2008-12-18:/archives/20081218155422</id> 46 <updated>2009-01-11T19:39:22Z</updated> 47 <published>2008-12-18T15:54:22Z</published> 48 <category scheme='http://diveintomark.org' term='asf'/> 49 <category scheme='http://diveintomark.org' term='avi'/> 50 <category scheme='http://diveintomark.org' term='encoding'/> 51 <category scheme='http://diveintomark.org' term='flv'/> 52 <category scheme='http://diveintomark.org' term='GIVE'/> 53 <category scheme='http://diveintomark.org' term='mp4'/> 54 <category scheme='http://diveintomark.org' term='ogg'/> 55 <category scheme='http://diveintomark.org' term='video'/> 56 <summary type='html'>这些笔记最终会成为一次关于视频编码的技术演讲的一部分。</summary> 57 </entry> 58</feed>