Home | Trees | Indices | Help |
|
---|
|
A class which is used to build XPath-like paths as a DOM tree is walked. It keeps track of the number of times which it has seen a certain tag, so that it will correctly create indices for tags.
Initially, the path is empty. Thus >>> xb = XPathBreadcrumb() >>> xb.xpath ""
Suppose we walk down a DOM node for the tag <foo> and we want to record this, we simply do >>> xb.start_tag('foo')
Now, the path is no longer empty. Thus >>> xb.xpath foo[0]
Now suppose there are two <bar> tags under the tag <foo> (that is <foo><bar></bar><bar></bar><foo>), then the breadcrumb will keep track of the number of times it sees <bar>. Thus
>>> xb.start_tag('bar') >>> xb.xpath foo[0]/bar[0] >>> xb.end_tag() >>> xb.xpath foo[0] >>> xb.start_tag('bar') >>> xb.xpath foo[0]/bar[1]
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
xpath | |||
Inherited from |
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
|
|
xpath
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Apr 12 18:12:00 2011 | http://epydoc.sourceforge.net |