Panda3D

- Main Page
- Packages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Attributes

# _ElementInterface Class Reference

Internal element class. More...

List of all members.

## Public Member Functions
def | __init__
def | __delitem__
| Deletes the given subelement.
def | __delslice__
| Deletes a number of subelements.
def | __getitem__
| Returns the given subelement.
def | __getslice__
| Returns a list containing subelements in the given range.
def | __len__
| Returns the number of subelements.
def | __repr__
def | __setitem__
| Replaces the given subelement.
def | __setslice__
| Replaces a number of subelements with elements from a sequence.
def | append
| Adds a subelement to the end of this element.
def | clear
| Resets an element.
def | find
| Finds the first matching subelement, by tag name or path.
def | findall
| Finds all matching subelements, by tag name or path.
def | findtext
| Finds text for the first matching subelement, by tag name or path.
def | get
| Gets an element attribute.
def | getchildren
| Returns all subelements.
def | getiterator
| Creates a tree iterator.
def | insert
| Inserts a subelement at the given position in this element.
def | items
| Gets element attributes, as a sequence.
def | keys
| Gets a list of attribute names.
def | makeelement
| Creates a new element object of the same type as this element.
def | remove
| Removes a matching subelement.
def | set
| Sets an element attribute.
## Static Public Attributes
| attrib = None
| (Attribute) Element attribute dictionary.
| tag = None
| (Attribute) Element tag.
| tail = None
| (Attribute) Text after this element's end tag, but before the next sibling element's start tag.
| text = None
| (Attribute) Text before first subelement.

## Detailed Description

Internal element class.

This class defines the Element interface, and provides a reference implementation of this interface.

You should not create instances of this class directly. Use the appropriate factory functions instead, such as Element and SubElement.

See also:
  Element
  SubElement
  Comment
  ProcessingInstruction

## Constructor & Destructor Documentation

def __init__ | ( |  | self,
|  |  | tag,
|  |  | attrib
| ) |  |

## Member Function Documentation

def __delitem__ | ( |  | self,
|  |  | index
| ) |  |

Deletes the given subelement.

Parameters:

  index | What subelement to delete.

Exceptions:

  IndexError | If the given element does not exist.

def __delslice__ | ( |  | self,
|  |  | start,
|  |  | stop
| ) |  |

Deletes a number of subelements.

Parameters:

  start | The first subelement to delete.
  stop | The first subelement to leave in there.

def __getitem__ | ( |  | self,
|  |  | index
| ) |  |

Returns the given subelement.

Parameters:

  index | What subelement to return.

Returns:
  The given subelement.

Exceptions:

  IndexError | If the given element does not exist.

def __getslice__ | ( |  | self,
|  |  | start,
|  |  | stop
| ) |  |

Returns a list containing subelements in the given range.

Parameters:

  start | The first subelement to return.
  stop | The first subelement that shouldn't be returned.

Returns:
  A sequence object containing subelements.

def __len__ | ( |  | self | ) |

Returns the number of subelements.

Returns:
  The number of subelements.

def __repr__ | ( |  | self | ) |

def __setitem__ | ( |  | self,
|  |  | index,
|  |  | element
| ) |  |

Replaces the given subelement.

Parameters:

  index | What subelement to replace.
  element | The new element value.

Exceptions:

  IndexError | If the given element does not exist.
  AssertionError | If element is not a valid object.

def __setslice__ | ( |  | self,
|  |  | start,
|  |  | stop,
|  |  | elements
| ) |  |

Replaces a number of subelements with elements from a sequence.

Parameters:

  start | The first subelement to replace.
  stop | The first subelement that shouldn't be replaced.
  elements | A sequence object with zero or more elements.

Exceptions:

  AssertionError | If a sequence member is not a valid object.

def append | ( |  | self,
|  |  | element
| ) |  |

Adds a subelement to the end of this element.

Parameters:

  element | The element to add.

Exceptions:

  AssertionError | If a sequence member is not a valid object.

def clear | ( |  | self | ) |

Resets an element.

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

def find | ( |  | self,
|  |  | path
| ) |  |

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

Parameters:

  path | What element to look for.

Returns:
  The first matching element, or None if no element was found. Element or None

def findall | ( |  | self,
|  |  | path
| ) |  |

Finds all matching subelements, by tag name or path.

Parameters:

  path | What element to look for.

Returns:
  A list or iterator containing all matching elements, in document order. list of Element instances

def findtext | ( |  | self,
|  |  | path,
|  |  | default = `None`
| ) |  |

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

Parameters:

  path | What element to look for.
  default | What to return if the element was not found.

Returns:
  The text content of the first matching element, or the default value no element was found. Note that if the element has is found, but has no text content, this method returns an empty string. string

def get | ( |  | self,
|  |  | key,
|  |  | default = `None`
| ) |  |

Gets an element attribute.

Parameters:

  key | What attribute to look for.
  default | What to return if the attribute was not found.

Returns:
  The attribute value, or the default value, if the attribute was not found. string or None

def getchildren | ( |  | self | ) |

Returns all subelements.

The elements are returned in document order.

Returns:
  A list of subelements. list of Element instances

def getiterator | ( |  | self,
|  |  | tag = `None`
| ) |  |

Creates a tree iterator.

The iterator loops over this element and all subelements, in document order, and returns all elements with a matching tag.

If the tree structure is modified during iteration, the result is undefined.

Parameters:

  tag | What tags to look for (default is to return all elements).

Returns:
  A list or iterator containing all the matching elements. list or iterator

def insert | ( |  | self,
|  |  | index,
|  |  | element
| ) |  |

Inserts a subelement at the given position in this element.

Parameters:

  index | Where to insert the new subelement.

Exceptions:

  AssertionError | If the element is not a valid object.

def items | ( |  | self | ) |

Gets element attributes, as a sequence.

The attributes are returned in an arbitrary order.

Returns:
  A list of (name, value) tuples for all attributes. list of (string, string) tuples

def keys | ( |  | self | ) |

Gets a list of attribute names.

The names are returned in an arbitrary order (just like for an ordinary Python dictionary).

Returns:
  A list of element attribute names. list of strings

def makeelement | ( |  | self,
|  |  | tag,
|  |  | attrib
| ) |  |

Creates a new element object of the same type as this element.

Parameters:

  tag | Element tag.
  attrib | Element attributes, given as a dictionary.

Returns:
  A new element instance.

def remove | ( |  | self,
|  |  | element
| ) |  |

Removes a matching subelement.

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

Parameters:

  element | What element to remove.

Exceptions:

  ValueError | If a matching element could not be found.
  AssertionError | If the element is not a valid object.

def set | ( |  | self,
|  |  | key,
|  |  | value
| ) |  |

Sets an element attribute.

Parameters:

  key | What attribute to set.
  value | The attribute value.

## Member Data Documentation

attrib = None`[static]`

(Attribute) Element attribute dictionary.

Where possible, use _ElementInterface.get, _ElementInterface.set, _ElementInterface.keys, and _ElementInterface.items to access element attributes.

tag = None`[static]`

(Attribute) Element tag.

tail = None`[static]`

(Attribute) Text after this element's end tag, but before the next sibling element's start tag.

This is either a string or the value None, if there was no text.

text = None`[static]`

(Attribute) Text before first subelement.

This is either a string or the value None, if there was no text.

All Classes Namespaces Functions Variables Enumerations Enumerator Properties