Mercurial > genshi > genshi-test
comparison 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 |
comparison
equal
deleted
inserted
replaced
509:1997f7af845c | 510:ca7d707d51b0 |
---|---|
60 | 60 |
61 ---------------- | 61 ---------------- |
62 Querying Streams | 62 Querying Streams |
63 ---------------- | 63 ---------------- |
64 | 64 |
65 :: | 65 The ``Stream`` class provides a ``select(path)`` function that can be used to |
66 retrieve subsets of the stream: | |
66 | 67 |
67 from genshi.input import XML | 68 .. code-block:: pycon |
68 | 69 |
69 doc = XML('''<doc> | 70 >>> from genshi.input import XML |
70 <items count="2"> | 71 |
71 <item status="new"> | 72 >>> doc = XML('''<doc> |
72 <summary>Foo</summary> | 73 ... <items count="2"> |
73 </item> | 74 ... <item status="new"> |
74 <item status="closed"> | 75 ... <summary>Foo</summary> |
75 <summary>Bar</summary> | 76 ... </item> |
76 </item> | 77 ... <item status="closed"> |
77 </items> | 78 ... <summary>Bar</summary> |
78 </doc>''') | 79 ... </item> |
79 print doc.select('items/item[@status="closed"]/summary/text()') | 80 ... </items> |
80 | 81 ... </doc>''') |
81 This would result in the following output:: | 82 |
82 | 83 >>> print doc.select('items/item[@status="closed"]/summary/text()') |
83 Bar | 84 Bar |
84 | 85 |
85 | 86 |
86 --------------------- | 87 --------------------- |
87 Matching in Templates | 88 Matching in Templates |