<?xml version="1.0" encoding="ascii"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>genshi.path</title> <link rel="stylesheet" href="epydoc.css" type="text/css" /> <script type="text/javascript" src="epydoc.js"></script> </head> <body bgcolor="white" text="black" link="blue" vlink="#204080" alink="#204080"> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="genshi-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th> </tr></table></th> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="100%"> <span class="breadcrumbs"> <a href="genshi-module.html">Package genshi</a> :: Module path </span> </td> <td> <table cellpadding="0" cellspacing="0"> <!-- hide/show private --> </table> </td> </tr> </table> <!-- ==================== MODULE DESCRIPTION ==================== --> <h1 class="epydoc">Module path</h1><p class="nomargin-top"></p> <p>Basic support for evaluating XPath expressions against streams.</p> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-keyword">from</span> genshi.input <span class="py-keyword">import</span> XML <span class="py-prompt">>>> </span>doc = XML(<span class="py-string">'''<doc></span> <span class="py-more">... </span><span class="py-string"> <items count="4"></span> <span class="py-more">... </span><span class="py-string"> <item status="new"></span> <span class="py-more">... </span><span class="py-string"> <summary>Foo</summary></span> <span class="py-more">... </span><span class="py-string"> </item></span> <span class="py-more">... </span><span class="py-string"> <item status="closed"></span> <span class="py-more">... </span><span class="py-string"> <summary>Bar</summary></span> <span class="py-more">... </span><span class="py-string"> </item></span> <span class="py-more">... </span><span class="py-string"> <item status="closed" resolution="invalid"></span> <span class="py-more">... </span><span class="py-string"> <summary>Baz</summary></span> <span class="py-more">... </span><span class="py-string"> </item></span> <span class="py-more">... </span><span class="py-string"> <item status="closed" resolution="fixed"></span> <span class="py-more">... </span><span class="py-string"> <summary>Waz</summary></span> <span class="py-more">... </span><span class="py-string"> </item></span> <span class="py-more">... </span><span class="py-string"> </items></span> <span class="py-more">... </span><span class="py-string"></doc>'''</span>) <span class="py-prompt">>>> </span><span class="py-keyword">print</span>(doc.select(<span class="py-string">'items/item[@status="closed" and '</span> <span class="py-more">... </span> <span class="py-string">'(@resolution="invalid" or not(@resolution))]/summary/text()'</span>)) <span class="py-output">BarBaz</span></pre> <p>Because the XPath engine operates on markup streams (as opposed to tree structures), it only implements a subset of the full XPath 1.0 language.</p> <!-- ==================== CLASSES ==================== --> <a name="section-Classes"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td align="left" colspan="2" class="table-header"> <span class="table-header">Classes</span></td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a href="genshi.path.Path-class.html" class="summary-name">Path</a><br /> Implements basic XPath support on streams. </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a href="genshi.path.PathSyntaxError-class.html" class="summary-name">PathSyntaxError</a><br /> Exception raised when an XPath expression is syntactically incorrect. </td> </tr> </table> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="genshi-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th> </tr></table></th> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="100%%"> <tr> <td align="left" class="footer"> Generated by Epydoc 3.0.1 on Sun Jan 27 18:17:20 2013 </td> <td align="right" class="footer"> <a target="mainFrame" href="http://epydoc.sourceforge.net" >http://epydoc.sourceforge.net</a> </td> </tr> </table> <script type="text/javascript"> <!-- // Private objects are initially displayed (because if // javascript is turned off then we want them to be // visible); but by default, we want to hide them. So hide // them unless we have a cookie that says to show them. checkCookie(); // --> </script> </body> </html>