(weblog) , CNN.com. (CNN.com), (Breaking News, U.S., World, Weather, Entertainment & Video News), ( 12:43 p.m. EDT, Sat May 16, 2009) . , (, , , ) URL.
Atom . CNN.com , , . .
Atom feed http://www.w3.org/2005/Atom.
<feed xmlns='http://www.w3.org/2005/Atom' ① xml:lang='en'> ②① http://www.w3.org/2005/Atom - Atom
② xml:lang . xml:lang .
Atom :
<feed xmlns='http://www.w3.org/2005/Atom' xml:lang='en'> <title>dive into mark</title> ① <subtitle>currently between addictions</subtitle> ② <id>tag:diveintomark.org,2001-07-29:/</id> ③ <updated>2009-03-27T21:56:07Z</updated> ④ <link rel='alternate' type='text/html' href='http://diveintomark.org/'/> ⑤① title 'dive into mark'.
② subtitle 'currently between addictions'.
③ . RFC 4151 .
④ 27 2009 21:56 GMT. updated - .
⑤ . link , : rel, type href. rel . rel='alternate' , . type='text/html' , HTML . , , href.
, dive into mark. http://diveintomark.org/ 27 2009.
XML , Atom - . |
: . :
|
|
① author , : (Mark), http://diveintomark.org/ ( , , , .)
② title Dive into history, 2009 edition.
③ , link HTML .
④ entry, , .
⑤ entry : .
⑥ entry category. diveintopython, docbook html.
⑦ summary . ( content .) summary Atom type='html' HTML. , HTML- — … , .
⑧ , , entry .
XML
Python XML c . DOM SAX, ElementTree.
>>> import xml.etree.ElementTree as etree ①>>> tree = etree.parse('examples/feed.xml') ②>>> root = tree.getroot() ③>>> root ④<Element {http://www.w3.org/2005/Atom}feed at cd1eb0>① ElementTree Python, xml.etree.ElementTree.
② parse() ElementTree. . . , XML .
③ parse() , . tree . , getroot().
|
|
④ , http://www.w3.org/2005/Atom. root : XML - ( ). Atom, {http://www.w3.org/2005/Atom}feed.
ElementTree XML '{ } '. API ElementTree. |