Class Manipulator
source code
object --+
|
Manipulator
a base class for processXML manipulators.
Pass instances of these into processXML. You must up-call the
constructor without arguments.
Override the gotElement(parseResult) method to do what you want. The
parseResult is a pyparsing object with the tag name in second position of
the first matched thing and the attributes barely parsed out (if you need
them, improve the parsing to get at the attributes with less effort.)
gotElement receives an entire element with opening tag, content, and
closing tag (or just an empty tag). To manipulate the thing, just return
what you want in the document.
There's also startElement(parsedOpener) that essentially works
analogously; you will, however *not* receive startElements for empty
elements, so that's really intended for bookkeeping.
You also have a hasParent(tagName) method on Manipulators returning
whether there's a tagName element somewhere among the ancestors of the
current tag.
|
|
|
|
|
|
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
Inherited from object :
__class__
|
x.__init__(...) initializes x; see help(type(x)) for signature
- Overrides:
object.__init__
- (inherited documentation)
|