Element class.
References a document object and a libxml node.
By pointing to a Document instance, a reference is kept to
_Document as long as there is some pointer to a node in it.
|
__contains__(self,
element) |
|
|
|
|
|
|
|
__delitem__(self,
x)
Deletes the given subelement or a slice. |
|
|
|
__getitem__(...)
Returns the subelement at the given position or the requested
slice. |
|
|
|
|
|
__len__(self)
Returns the number of subelements. |
|
|
a new object with type S, a subtype of T
|
|
|
|
|
|
|
|
|
__setitem__(self,
x,
value)
Replaces the given subelement index or slice. |
|
|
|
_init(self)
Called after object initialisation. Custom subclasses may override
this if they recursively call _init() in the superclasses. |
|
|
|
addnext(self,
element)
Adds the element as a following sibling directly after this
element. |
|
|
|
addprevious(self,
element)
Adds the element as a preceding sibling directly before this
element. |
|
|
|
append(self,
element)
Adds a subelement to the end of this element. |
|
|
|
clear(self)
Resets an element. This function removes all subelements, clears
all attributes and sets the text and tail properties to None. |
|
|
|
cssselect(...)
Run the CSS expression on this element and its children,
returning a list of the results. |
|
|
|
extend(self,
elements)
Extends the current children by the elements in the iterable. |
|
|
|
find(self,
path,
namespaces=None)
Finds the first matching subelement, by tag name or path. |
|
|
|
findall(self,
path,
namespaces=None)
Finds all matching subelements, by tag name or path. |
|
|
|
findtext(self,
path,
default=None,
namespaces=None)
Finds text for the first matching subelement, by tag name or path. |
|
|
|
get(self,
key,
default=None)
Gets an element attribute. |
|
|
|
getchildren(self)
Returns all direct children. The elements are returned in document
order. |
|
|
|
getiterator(self,
tag=None,
*tags)
Returns a sequence or iterator of all elements in the subtree in
document order (depth first pre-order), starting with this
element. |
|
|
|
getnext(self)
Returns the following sibling of this element or None. |
|
|
|
getparent(self)
Returns the parent of this element or None for the root element. |
|
|
|
getprevious(self)
Returns the preceding sibling of this element or None. |
|
|
|
getroottree(self)
Return an ElementTree for the root node of the document that
contains this element. |
|
|
|
index(self,
child,
start=None,
stop=None)
Find the position of the child within the parent. |
|
|
|
insert(self,
index,
element)
Inserts a subelement at the given position in this element |
|
|
|
items(self)
Gets element attributes, as a sequence. The attributes are returned in
an arbitrary order. |
|
|
|
iter(self,
tag=None,
*tags)
Iterate over all elements in the subtree in document order (depth
first pre-order), starting with this element. |
|
|
|
iterancestors(self,
tag=None,
*tags)
Iterate over the ancestors of this element (from parent to parent). |
|
|
|
iterchildren(self,
tag=None,
reversed=False,
*tags)
Iterate over the children of this element. |
|
|
|
iterdescendants(self,
tag=None,
*tags)
Iterate over the descendants of this element in document order. |
|
|
|
iterfind(self,
path,
namespaces=None)
Iterates over all matching subelements, by tag name or path. |
|
|
|
itersiblings(self,
tag=None,
preceding=False,
*tags)
Iterate over the following or preceding siblings of this element. |
|
|
|
itertext(self,
tag=None,
with_tail=True,
*tags)
Iterates over the text content of a subtree. |
|
|
|
keys(self)
Gets a list of attribute names. The names are returned in an
arbitrary order (just like for an ordinary Python dictionary). |
|
|
|
makeelement(self,
_tag,
attrib=None,
nsmap=None,
**_extra)
Creates a new element associated with the same document. |
|
|
|
remove(self,
element)
Removes a matching subelement. Unlike the find methods, this
method compares elements based on identity, not on tag value
or contents. |
|
|
|
replace(self,
old_element,
new_element)
Replaces a subelement with the element passed as second argument. |
|
|
|
set(self,
key,
value)
Sets an element attribute. |
|
|
|
values(self)
Gets element attribute values as a sequence of strings. The
attributes are returned in an arbitrary order. |
|
|
|
xpath(self,
_path,
namespaces=None,
extensions=None,
smart_strings=True,
**_variables)
Evaluate an xpath expression using the element as context node. |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__init__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|