class documentation

class ElementWrapper(object): (source)

Constructor: ElementWrapper(etree)

View In Hierarchy

A wrapper around ElementTree Element objects whose main purpose is to provide nicer __repr__ and __str__ methods. In addition, any of the wrapped Element's methods that return other Element objects are overridden to wrap those values before returning them.

This makes Elements more convenient to work with in interactive sessions and doctests, at the expense of some efficiency.

Method __delattr__ Undocumented
Method __delitem__ Undocumented
Method __delslice__ Undocumented
Method __getattr__ Undocumented
Method __getitem__ Undocumented
Method __getslice__ Undocumented
Method __init__ Initialize a new Element wrapper for etree.
Method __len__ Undocumented
Method __new__ Create and return a wrapper around a given Element object. If etree is an ElementWrapper, then etree is returned as-is.
Method __repr__ Undocumented
Method __setattr__ Undocumented
Method __setitem__ Undocumented
Method __setslice__ Undocumented
Method __str__ the wrapped Element object.
Method find Undocumented
Method findall Undocumented
Method getchildren Undocumented
Method getiterator Undocumented
Method makeelement Undocumented
Method unwrap Return the Element object wrapped by this wrapper.
def __delattr__(self, attr): (source)

Undocumented

def __delitem__(self, index): (source)

Undocumented

def __delslice__(self, start, stop): (source)

Undocumented

def __getattr__(self, attrib): (source)

Undocumented

def __getitem__(self, index): (source)

Undocumented

def __getslice__(self, start, stop): (source)

Undocumented

def __init__(self, etree): (source)

Initialize a new Element wrapper for etree.

If etree is a string, then it will be converted to an Element object using ElementTree.fromstring() first:

>>> ElementWrapper("<test></test>")
<Element "<?xml version='1.0' encoding='utf8'?>\n<test />">
def __len__(self): (source)

Undocumented

def __new__(cls, etree): (source)

Create and return a wrapper around a given Element object. If etree is an ElementWrapper, then etree is returned as-is.

def __repr__(self): (source)

Undocumented

def __setattr__(self, attr, value): (source)

Undocumented

def __setitem__(self, index, element): (source)

Undocumented

def __setslice__(self, start, stop, elements): (source)

Undocumented

def __str__(self): (source)

the wrapped Element object.

Returns
the result of applying ElementTree.tostring() to
def find(self, path): (source)

Undocumented

def findall(self, path): (source)

Undocumented

def getchildren(self): (source)

Undocumented

def getiterator(self, tag=None): (source)

Undocumented

def makeelement(self, tag, attrib): (source)

Undocumented

def unwrap(self): (source)

Return the Element object wrapped by this wrapper.