Main XML Element class.
Element children are accessed as object attributes. Multiple children
with the same name are available through a list index. Example:
Note that you cannot (and must not) instantiate this class or its
subclasses.
|
|
|
|
|
|
|
|
__getattr__(...)
Return the (first) child with the given tag name. If no namespace
is provided, the child will be looked up in the same one as self.
|
|
|
|
|
|
__getitem__(...)
Return a sibling, counting from the first child of the parent. The
method behaves like both a dict and a sequence.
|
|
|
__iter__(...)
Iterate over self and all siblings with the same tag.
|
|
|
__len__(...)
Count self and siblings with the same tag.
|
|
a new object with type S, a subtype of T
|
|
|
|
|
|
|
__setattr__(...)
Set the value of the (first) child with the given tag name. If no
namespace is provided, the child will be looked up in the same one as
self.
|
|
|
__setitem__(...)
Set the value of a sibling, counting from the first child of the
parent. Implements key assignment, item assignment and slice
assignment.
|
|
|
|
|
|
addattr(self,
tag,
value)
Add a child value to the element.
|
|
|
countchildren(self)
Return the number of children of this element, regardless of their
name.
|
|
|
descendantpaths(self,
prefix=None)
Returns a list of object path expressions for all descendants.
|
|
|
getchildren(self)
Returns a sequence of all direct children. The elements are
returned in document order.
|
|
Inherited from etree.ElementBase :
__init__
Inherited from etree._Element :
__contains__ ,
__copy__ ,
__deepcopy__ ,
__nonzero__ ,
__repr__ ,
__reversed__ ,
addnext ,
addprevious ,
append ,
clear ,
cssselect ,
extend ,
find ,
findall ,
findtext ,
get ,
getiterator ,
getnext ,
getparent ,
getprevious ,
getroottree ,
index ,
insert ,
items ,
iter ,
iterancestors ,
iterchildren ,
iterdescendants ,
iterfind ,
itersiblings ,
itertext ,
keys ,
makeelement ,
remove ,
replace ,
set ,
values ,
xpath
Inherited from object:
__format__,
__hash__,
__reduce_ex__,
__sizeof__,
__subclasshook__
|
|
|
text
Text before the first subelement. This is either a string or
the value None, if there was no text.
|
|
Inherited from etree._Element :
attrib ,
base ,
nsmap ,
prefix ,
sourceline ,
tag ,
tail
Inherited from object:
__class__
|
__delattr__(...)
x.__delattr__('name') <==> del x.name
- Overrides:
object.__delattr__
__getattribute__(...)
x.__getattribute__('name') <==> x.name
- Overrides:
object.__getattribute__
__getitem__(...)
(Indexing operator)
Return a sibling, counting from the first child of the parent. The
method behaves like both a dict and a sequence.
- If argument is an integer, returns the sibling at that position.
- If argument is a string, does the same as getattr(). This can be
used to provide namespaces for element lookup, or to look up
children with special names (text etc.).
- If argument is a slice object, returns the matching slice.
- Overrides:
etree._Element.__getitem__
__new__(T,
S,
...)
- Returns: a new object with type S, a subtype of T
- Overrides:
object.__new__
__reduce__(...)
helper for pickle
- Overrides:
object.__reduce__
- (inherited documentation)
__setattr__(...)
Set the value of the (first) child with the given tag name. If no
namespace is provided, the child will be looked up in the same one as
self.
- Overrides:
object.__setattr__
__setitem__(...)
(Index assignment operator)
Set the value of a sibling, counting from the first child of the
parent. Implements key assignment, item assignment and slice
assignment.
- If argument is an integer, sets the sibling at that position.
- If argument is a string, does the same as setattr(). This is used
to provide namespaces for element lookup.
- If argument is a sequence (list, tuple, etc.), assign the contained
items to the siblings.
- Overrides:
etree._Element.__setitem__
__str__(x)
(Informal representation operator)
str(x)
- Overrides:
object.__str__
addattr(self,
tag,
value)
Add a child value to the element.
As opposed to append(), it sets a data value, not an element.
getchildren(self)
Returns a sequence of all direct children. The elements are
returned in document order.
- Overrides:
etree._Element.getchildren