Panda3D
|
ElementTree wrapper class. More...
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. |
ElementTree wrapper class.
This class represents an entire element hierarchy, and adds some extra support for serialization to and from standard XML.
element | Optional root element. file Optional file handle or name. If given, the tree is initialized with the contents of this XML file. |
def __init__ | ( | self, | |
element = None , |
|||
file = None |
|||
) |
def find | ( | self, | |
path | |||
) |
Finds the first toplevel element with given tag.
Same as getroot().find(path).
path | What element to look for. |
def findall | ( | self, | |
path | |||
) |
Finds all toplevel elements with the given tag.
Same as getroot().findall(path).
path | What element to look for. |
def findtext | ( | self, | |
path, | |||
default = None |
|||
) |
Finds the element text for the first toplevel element with given tag.
Same as getroot().findtext(path).
path | What toplevel element to look for. |
default | What to return if the element was not found. |
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.
tag | What tags to look for (default is to return all elements) |
def getroot | ( | self | ) |
Gets the root element for this tree.
def parse | ( | self, | |
source, | |||
parser = None |
|||
) |
Loads an external XML document into this element tree.
source | A file name or file object. |
parser | An optional parser instance. If not given, the standard XMLTreeBuilder parser is used. |
def write | ( | self, | |
file, | |||
encoding = "us-ascii" |
|||
) |
Writes the element tree to a file, as XML.
file | A file name, or a file object opened for writing. |
encoding | Optional output encoding (default is US-ASCII). |