diff --git a/xml.html b/xml.html index 03b5547..59754d2 100644 --- a/xml.html +++ b/xml.html @@ -298,19 +298,7 @@ mark{display:inline}
XML isn’t just a collection of elements; each element can also have its own set of attributes. Once you have a reference to a specific element, you can easily get its attributes as a Python dictionary. -
To refresh your memory, here is the first few lines of feed.xml, the XML document we’re working with.
-
-
<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/"/>
- <link rel="self" type="application/atom+xml" href="http://diveintomark.org/feed/"/>
-...
-<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> -FIXME # continuing from the previous example >>> root.attrib ① {'{http://www.w3.org/XML/1998/namespace}lang': 'en'} @@ -325,11 +313,11 @@ FIXME >>> root[3].attrib ⑤ {}
attrib property is a dictionary of the element’s attributes. The original markup here was <feed xmlns
--
-
-
-
-
-
-
+
- The
attrib property is a dictionary of the element’s attributes. The original markup here was <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">. The xml: prefix refers to a built-in namespace that every XML document can use without declaring it.
+ - The fifth child —
[4] in a 0-based list — is the link element.
+ - The
link element has three attributes: href, type, and rel.
+ - The fourth child —
[3] in a 0-based list — is the updated element.
+ - The
updated element has no attributes, so its .attrib is just an empty dictionary.