create with the general syntax: `w.name( child1 , .. , attribute1 = value1 , .. )`.
Attributes make sense only for `Element` node type however.
+It's also possible to pass a function, which take no parameters and
+should return a correct XML tree. This function will be called at
+serialization time.
+
-=-=-
w._doc_(
w.html(
TEXT[23] 'Bla bla bla.'
-=-=-
+Example of deferred function:
+
+-=-=-
+count = 0
+def foo() :
+ global count
+ count += 1
+ return w.p( "I'm generated %d time(s)." % count )
+
+doc = w.body( foo )
+
+print doc.serialize()
+print doc.serialize()
+print doc.serialize()
+-=-=-
+
+produce:
+
+-=-=-
+<body><p>I'm generated 1 time(s).</p></body>
+<body><p>I'm generated 2 time(s).</p></body>
+<body><p>I'm generated 3 time(s).</p></body>
+-=-=-
+
= XPath =
The module `xpath` provide a large subset of XPath 2.0.
<title>Slashdot: News for nerds, stuff that matters</title>
-=-=-
- * Extracting articles title:
+ * Extracting articles title (pre-september 2005):
-=-=-
XPath2.0> \s
5 STRING Your Rights Online: Is Your Boss a Psychopath?
6 STRING Linux: Australian Linux Trademark Holds Water
7 STRING Science: Nanotubes Start to Show their Promise
+-=-=-
+
+ * Extracting articles title (post-september 2005):
+
+ -=-=-
+XPath2.0> \s
+[short]
+XPath2.0> //div[@class='generaltitle']/normalize-space()
+1 STRING Tivo Institutes 1 Year Service Contracts
+2 STRING Politics: US Senate Allows NASA To Buy Soyuz Vehicles
+3 STRING IT: Reconnaissance In Virtual Space
+4 STRING Your Rights Online: FBI Agents Put New Focus on Deviant Porn
+5 STRING Ask Slashdot: Top 50 Science Fiction TV Shows
+6 STRING Your Rights Online: Business At The Price Of Freedom
+7 STRING Apple: Music Exec Fires Back At Apple CEO
+8 STRING Science: Grammar Traces Language Roots
+9 STRING Developers: RMS Previews GPL3 Terms
+10 STRING Massachusetts Finalizes OpenDocument Standard Plan
+11 STRING Developers: Palm Teams With Microsoft for Smart Phone
+12 STRING Developers: Why Vista Had To Be Rebuilt From Scratch
+13 STRING Hardware: Nabaztag the WiFi Bunny
+14 STRING Revamping the Movie Distribution Chain
+15 STRING Politics: Municipal Broadband Projects Spread Across U.S.
-=-=-
* Extracting RSS title from an external document:
XPath2.0> \s
[short]
XPath2.0> doc('http://rss.slashdot.org/Slashdot/slashdot')//item/title/string()
-1 STRING Toshiba May Delay HD-DVD Launch to 2006
-2 STRING FCC Seeks Tech Donations for Katrina Aid
-3 STRING Balmer Vows to Kill Google
-4 STRING Bill Gates To Star With Steve Jobs On Broadway
-5 STRING Dead Star Set to Escape the Milky Way
-6 STRING Fuddruckers Called Out on Hotlinking
-7 STRING The View from the Top of Husband Hill
-8 STRING Google Plans To Destroy Unindexed Information
-9 STRING Nikon Releases WiFi Digital Camera
-10 STRING EU Gumshoe Chases Internet Villains
+1 STRING Tivo Institutes 1 Year Service Contracts
+2 STRING US Senate Allows NASA To Buy Soyuz Vehicles
+3 STRING Reconnaissance In Virtual Space
+4 STRING FBI Agents Put New Focus on Deviant Porn
+5 STRING Top 50 Science Fiction TV Shows
+6 STRING Business At The Price Of Freedom
+7 STRING Music Exec Fires Back At Apple CEO
+8 STRING Grammar Traces Language Roots
+9 STRING RMS Previews GPL3 Terms
+10 STRING Massachusetts Finalizes OpenDocument Standard Plan
-=-=-
* Extracting 1st, 3rd and 7th comment of the document:
-=-=-
* Looking for `rel` attribute, with location (the XPath expression
- that could be used to identify precisely the node in the resulting
- sequence):
+ that could be used to identify precisely the node in the resulting
+ sequence):
-=-=-
XPath2.0> \f
*Note*: Internally patterns are translated to XPath expression. Such
expression return the empty sequence if pattern doesn't match the
-node.
+node. For example, `a/b` become something like
+`self::element(b)/parent::element(a)`.
= Parsing HTML =