Package lxml :: Module etree :: Class _Element
[show private | hide private]
[frames | no frames]

Type _Element

object --+
         |
        _Element

Known Subclasses:
ElementBase, __ContentOnlyElement

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.
Method Summary
  __contains__(x, y)
x.__contains__(y) <==> y in x
  __copy__(...)
  __deepcopy__(...)
  __delitem__(x, y)
x.__delitem__(y) <==> del x[y]
  __delslice__(x, i, j)
Use of negative indices is not supported.
  __getitem__(x, y)
x.__getitem__(y) <==> x[y]
  __getslice__(x, i, j)
Use of negative indices is not supported.
  __iter__(x)
x.__iter__() <==> iter(x)
  __len__(x)
x.__len__() <==> len(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __nonzero__(x)
x.__nonzero__() <==> x != 0
  __repr__(x)
x.__repr__() <==> repr(x)
  __reversed__(...)
  __setitem__(x, i, y)
x.__setitem__(i, y) <==> x[i]=y
  __setslice__(x, i, j, y)
Use of negative indices is not supported.
  _init(...)
Called after object initialisation.
  addnext(...)
Adds the element as a following sibling directly after this element.
  addprevious(...)
Adds the element as a preceding sibling directly before this element.
  append(...)
Adds a subelement to the end of this element.
  clear(...)
Resets an element.
  extend(...)
Extends the current children by the elements in the iterable.
  find(...)
Finds the first matching subelement, by tag name or path.
  findall(...)
Finds all matching subelements, by tag name or path.
  findtext(...)
Finds text for the first matching subelement, by tag name or path.
  get(...)
Gets an element attribute.
  getchildren(...)
Returns all subelements.
  getiterator(...)
Iterate over all elements in the subtree in document order (depth first pre-order), starting with this element.
  getnext(...)
Returns the following sibling of this element or None.
  getparent(...)
Returns the parent of this element or None for the root element.
  getprevious(...)
Returns the preceding sibling of this element or None.
  getroottree(...)
Return an ElementTree for the root node of the document that contains this element.
  index(...)
Find the position of the child within the parent.
  insert(...)
Inserts a subelement at the given position in this element
  items(...)
Gets element attributes, as a sequence.
  iter(...)
Iterate over all elements in the subtree in document order (depth first pre-order), starting with this element.
  iterancestors(...)
Iterate over the ancestors of this element (from parent to parent).
  iterchildren(...)
Iterate over the children of this element.
  iterdescendants(...)
Iterate over the descendants of this element in document order.
  itersiblings(...)
Iterate over the following or preceding siblings of this element.
  keys(...)
Gets a list of attribute names.
  makeelement(...)
Creates a new element associated with the same document.
  remove(...)
Removes a matching subelement.
  replace(...)
Replaces a subelement with the element passed as second argument.
  set(...)
Sets an element attribute.
  values(...)
Gets element attribute values as a sequence of strings.
  xpath(...)
Evaluate an xpath expression using the element as context node.
    Inherited from object
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
getset_descriptor attrib = <attribute 'attrib' of 'lxml.etree._Element' ob...
getset_descriptor nsmap = <attribute 'nsmap' of 'lxml.etree._Element' obje...
getset_descriptor prefix = <attribute 'prefix' of 'lxml.etree._Element' ob...
getset_descriptor sourceline = <attribute 'sourceline' of 'lxml.etree._Ele...
getset_descriptor tag = <attribute 'tag' of 'lxml.etree._Element' objects>
getset_descriptor tail = <attribute 'tail' of 'lxml.etree._Element' object...
getset_descriptor text = <attribute 'text' of 'lxml.etree._Element' object...

Method Details

__contains__(x, y)
(In operator)

x.__contains__(y) <==> y in x
Returns:
y in x

__delitem__(x, y)
(Index deletion operator)

x.__delitem__(y) <==> del x[y]
Returns:
del x[y]

__delslice__(x, i, j)
(Slice deletion operator)

Use of negative indices is not supported.
Returns:
del x[i:j]

__getitem__(x, y)
(Indexing operator)

x.__getitem__(y) <==> x[y]
Returns:
x[y]

__getslice__(x, i, j)
(Slicling operator)

Use of negative indices is not supported.
Returns:
x[i:j]

__iter__(x)

x.__iter__() <==> iter(x)
Returns:
iter(x)

__len__(x)
(Length operator)

x.__len__() <==> len(x)
Returns:
len(x)

__new__(T, S, ...)

T.__new__(S, ...) -> a new object with type S, a subtype of T
Returns:
a new object with type S, a subtype of T
Overrides:
__builtin__.object.__new__

__nonzero__(x)
(Boolean test operator)

x.__nonzero__() <==> x != 0
Returns:
x != 0

__repr__(x)
(Representation operator)

x.__repr__() <==> repr(x)
Returns:
repr(x)
Overrides:
__builtin__.object.__repr__

__setitem__(x, i, y)
(Index assignment operator)

x.__setitem__(i, y) <==> x[i]=y
Returns:
x[i]=y

__setslice__(x, i, j, y)
(Slice assignment operator)

Use of negative indices is not supported.
Returns:
x[i:j]=y

_init(...)

Called after object initialisation. Custom subclasses may override this if they recursively call _init() in the superclasses.

addnext(...)

Adds the element as a following sibling directly after this element.

This is normally used to set a processing instruction or comment after the root node of a document. Note that tail text is automatically discarded when adding at the root level.

addprevious(...)

Adds the element as a preceding sibling directly before this element.

This is normally used to set a processing instruction or comment before the root node of a document. Note that tail text is automatically discarded when adding at the root level.

append(...)

Adds a subelement to the end of this element.

clear(...)

Resets an element. This function removes all subelements, clears all attributes and sets the text and tail attributes to None.

extend(...)

Extends the current children by the elements in the iterable.

find(...)

Finds the first matching subelement, by tag name or path.

findall(...)

Finds all matching subelements, by tag name or path.

findtext(...)

Finds text for the first matching subelement, by tag name or path.

get(...)

Gets an element attribute.

getchildren(...)

Returns all subelements. The elements are returned in document order.

getiterator(...)

Iterate over all elements in the subtree in document order (depth first pre-order), starting with this element.

Can be restricted to find only elements with a specific tag or from a namespace.

You can also pass the Element, Comment, ProcessingInstruction and Entity factory functions to look only for the specific element type.

Note that this method is deprecated in favour of the ``el.iter()`` method. In new code, use it only for backwards compatibility.

getnext(...)

Returns the following sibling of this element or None.

getparent(...)

Returns the parent of this element or None for the root element.

getprevious(...)

Returns the preceding sibling of this element or None.

getroottree(...)

Return an ElementTree for the root node of the document that contains this element.

This is the same as following element.getparent() up the tree until it returns None (for the root element) and then build an ElementTree for the last parent that was returned.

index(...)

Find the position of the child within the parent.

This method is not part of the original ElementTree API.

insert(...)

Inserts a subelement at the given position in this element

items(...)

Gets element attributes, as a sequence. The attributes are returned in an arbitrary order.

iter(...)

Iterate over all elements in the subtree in document order (depth first pre-order), starting with this element.

Can be restricted to find only elements with a specific tag or from a namespace.

You can also pass the Element, Comment, ProcessingInstruction and Entity factory functions to look only for the specific element type.

iterancestors(...)

Iterate over the ancestors of this element (from parent to parent).

The generated elements can be restricted to a specific tag name with the 'tag' keyword.

iterchildren(...)

Iterate over the children of this element.

As opposed to using normal iteration on this element, the generated elements can be restricted to a specific tag name with the 'tag' keyword and reversed with the 'reversed' keyword.

iterdescendants(...)

Iterate over the descendants of this element in document order.

As opposed to ``el.iter()``, this iterator does not yield the element itself. The generated elements can be restricted to a specific tag name with the 'tag' keyword.

itersiblings(...)

Iterate over the following or preceding siblings of this element.

The direction is determined by the 'preceding' keyword which defaults to False, i.e. forward iteration over the following siblings. The generated elements can be restricted to a specific tag name with the 'tag' keyword.

keys(...)

Gets a list of attribute names. The names are returned in an arbitrary order (just like for an ordinary Python dictionary).

makeelement(...)

Creates a new element associated with the same document.

remove(...)

Removes a matching subelement. Unlike the find methods, this method compares elements based on identity, not on tag value or contents.

replace(...)

Replaces a subelement with the element passed as second argument.

set(...)

Sets an element attribute.

values(...)

Gets element attribute values as a sequence of strings. The attributes are returned in an arbitrary order.

xpath(...)

Evaluate an xpath expression using the element as context node.

Class Variable Details

attrib

Type:
getset_descriptor
Value:
<attribute 'attrib' of 'lxml.etree._Element' objects>                  

nsmap

Type:
getset_descriptor
Value:
<attribute 'nsmap' of 'lxml.etree._Element' objects>                   

prefix

Type:
getset_descriptor
Value:
<attribute 'prefix' of 'lxml.etree._Element' objects>                  

sourceline

Type:
getset_descriptor
Value:
<attribute 'sourceline' of 'lxml.etree._Element' objects>              

tag

Type:
getset_descriptor
Value:
<attribute 'tag' of 'lxml.etree._Element' objects>                     

tail

Type:
getset_descriptor
Value:
<attribute 'tail' of 'lxml.etree._Element' objects>                    

text

Type:
getset_descriptor
Value:
<attribute 'text' of 'lxml.etree._Element' objects>                    

Generated by Epydoc 2.1 on Sat Aug 18 12:44:27 2007 http://epydoc.sf.net