Changeset 2854:54d2c044a162 in livinglogic.python.xist

Show
Ignore:
Timestamp:
08/03/07 18:24:14 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Add an example to the nthoftype docstring.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/xfind.py

    r2853 r2854  
    12181218    """ 
    12191219    <par>An <class>nthchild</class> object is a selector that selects every node 
    1220     that is the n-th node of a specified type. Similar to 
    1221     <pyref class="nthchild"><class>nthchild</class></pyref> <class>nthchild</class> 
     1220    that is the n-th node of a specified type among its siblings. Similar to 
     1221    <pyref class="nthchild"><class>nthchild</class></pyref> <class>nthoftype</class> 
    12221222    supports negative and positive indices as well as <lit>"even"</lit> and 
    1223     <lit>"odd"</lit>.</par> 
     1223    <lit>"odd"</lit>. Which types are checked can be passed explicitely. If no 
     1224    types are passed the type of the node itself is used.</par> 
     1225 
     1226    <example> 
     1227    <tty> 
     1228    <prompt>>>> </prompt><input>from ll.xist import parsers, xfind</input> 
     1229    <prompt>>>> </prompt><input>from ll.xist.ns import html</input> 
     1230    <prompt>>>> </prompt><input>doc = parsers.parseURL("http://www.python.org", tidy=True)</input> 
     1231    <prompt>>>> </prompt><input>for node in doc.walknode(<em>xfind.nthoftype(0, html.h2)</em>):</input> 
     1232    <prompt>... </prompt><input>\tprint node.bytes()</input> 
     1233    <prompt>... </prompt><input></input> 
     1234    <![CDATA[<h2 class="news">SciPy 2007 - Conference for Scientific Computing</h2>]]> 
     1235    </tty> 
     1236    </example> 
    12241237    """ 
    12251238