Panda3D
Public Member Functions

ElementTree Class Reference

ElementTree wrapper class. More...

List of all members.

Public Member Functions

def __init__
def find
 Finds the first toplevel element with given tag.
def findall
 Finds all toplevel elements with the given tag.
def findtext
 Finds the element text for the first toplevel element with given tag.
def getiterator
 Creates a tree iterator for the root element.
def getroot
 Gets the root element for this tree.
def parse
 Loads an external XML document into this element tree.
def write
 Writes the element tree to a file, as XML.

Detailed Description

ElementTree wrapper class.

This class represents an entire element hierarchy, and adds some extra support for serialization to and from standard XML.

Parameters:
elementOptional root element. file Optional file handle or name. If given, the tree is initialized with the contents of this XML file.

Constructor & Destructor Documentation

def __init__ (   self,
  element = None,
  file = None 
)

Member Function Documentation

def find (   self,
  path 
)

Finds the first toplevel element with given tag.

Same as getroot().find(path).

Parameters:
pathWhat 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 toplevel elements with the given tag.

Same as getroot().findall(path).

Parameters:
pathWhat 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 the element text for the first toplevel element with given tag.

Same as getroot().findtext(path).

Parameters:
pathWhat toplevel element to look for.
defaultWhat 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 getiterator (   self,
  tag = None 
)

Creates a tree iterator for the root element.

The iterator loops over all elements in this tree, in document order.

Parameters:
tagWhat tags to look for (default is to return all elements)
Returns:
An iterator. iterator
def getroot (   self)

Gets the root element for this tree.

Returns:
An element instance. Element
def parse (   self,
  source,
  parser = None 
)

Loads an external XML document into this element tree.

Parameters:
sourceA file name or file object.
parserAn optional parser instance. If not given, the standard XMLTreeBuilder parser is used.
Returns:
The document root element. Element
def write (   self,
  file,
  encoding = "us-ascii" 
)

Writes the element tree to a file, as XML.

Parameters:
fileA file name, or a file object opened for writing.
encodingOptional output encoding (default is US-ASCII).
 All Classes Namespaces Functions Variables Properties