Mercurial > genshi > genshi-test
diff doc/xpath.txt @ 510:ca7d707d51b0
Use syntax highlighting on all the other doc pages, too.
author | cmlenz |
---|---|
date | Wed, 06 Jun 2007 10:41:41 +0000 |
parents | ebc7c1a3bc4d |
children | 0e5a25f1b83d |
line wrap: on
line diff
--- a/doc/xpath.txt +++ b/doc/xpath.txt @@ -62,24 +62,25 @@ Querying Streams ---------------- -:: - - from genshi.input import XML +The ``Stream`` class provides a ``select(path)`` function that can be used to +retrieve subsets of the stream: - doc = XML('''<doc> - <items count="2"> - <item status="new"> - <summary>Foo</summary> - </item> - <item status="closed"> - <summary>Bar</summary> - </item> - </items> - </doc>''') - print doc.select('items/item[@status="closed"]/summary/text()') +.. code-block:: pycon -This would result in the following output:: - + >>> from genshi.input import XML + + >>> doc = XML('''<doc> + ... <items count="2"> + ... <item status="new"> + ... <summary>Foo</summary> + ... </item> + ... <item status="closed"> + ... <summary>Bar</summary> + ... </item> + ... </items> + ... </doc>''') + + >>> print doc.select('items/item[@status="closed"]/summary/text()') Bar