panda3d.core.TiXmlNode

from panda3d.core import TiXmlNode
class TiXmlNode

Bases: TiXmlBase

The parent class for everything in the Document Object Model. (Except for attributes). Nodes have siblings, a parent, and children. A node can be in a document, or stand on its own. The type of a TiXmlNode can be queried, and it can be cast to its more defined type.

Inheritance diagram

Inheritance diagram of TiXmlNode

Value() → str

The meaning of ‘value’ changes for the specific type of TiXmlNode.

Document:   filename of the xml file
Element:    name of the element
Comment:    the comment text
Unknown:    the tag contents
Text:       the text string

The subclasses will wrap this function.

ValueStr() → str

Return Value() as a std::string. If you only use STL, this is more efficient than calling Value(). Only available in STL mode.

ValueTStr() → str
SetValue(_value: str) → None

Changes the value of the node. Defined as:

Document:   filename of the xml file
Element:    name of the element
Comment:    the comment text
Unknown:    the tag contents
Text:       the text string
SetValue(_value: str) → None

/// STL std::string form.

Clear() → None

/// Delete all the children of this node. Does not affect ‘this’.

Parent() → TiXmlNode

/// One step up the DOM.

Return type

TiXmlNode

Parent() → TiXmlNode
Return type

TiXmlNode

FirstChild() → TiXmlNode

///< The first child of this node. Will be null if there are no children.

Return type

TiXmlNode

FirstChild() → TiXmlNode

///< The first child of this node. Will be null if there are no children.

Return type

TiXmlNode

FirstChild(_value: str) → TiXmlNode

///< The first child of this node with the matching ‘value’. Will be null if none found. /// The first child of this node with the matching ‘value’. Will be null if none found.

Return type

TiXmlNode

FirstChild(value: str) → TiXmlNode
Return type

TiXmlNode

FirstChild(_value: str) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

FirstChild(_value: str) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

LastChild() → TiXmlNode

/// The last child of this node. Will be null if there are no children.

Return type

TiXmlNode

LastChild() → TiXmlNode

/// The last child of this node. Will be null if there are no children.

Return type

TiXmlNode

LastChild(_value: str) → TiXmlNode

/// The last child of this node matching ‘value’. Will be null if there are no children.

Return type

TiXmlNode

LastChild(value: str) → TiXmlNode

/// The last child of this node matching ‘value’. Will be null if there are no children.

Return type

TiXmlNode

LastChild(_value: str) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

LastChild(_value: str) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

IterateChildren(previous: TiXmlNode) → TiXmlNode
Return type

TiXmlNode

IterateChildren(previous: TiXmlNode) → TiXmlNode

An alternate way to walk the children of a node. One way to iterate over nodes is:

for( child = parent->FirstChild(); child; child = child->NextSibling() )

IterateChildren does the same thing with the syntax:

child = 0;
while( child = parent->IterateChildren( child ) )

IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done.

Return type

TiXmlNode

IterateChildren(_value: str, previous: TiXmlNode) → TiXmlNode
Return type

TiXmlNode

IterateChildren(value: str, previous: TiXmlNode) → TiXmlNode

/// This flavor of IterateChildren searches for children with a particular ‘value’

Return type

TiXmlNode

IterateChildren(_value: str, previous: TiXmlNode) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

IterateChildren(_value: str, previous: TiXmlNode) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

InsertEndChild(addThis: TiXmlNode) → TiXmlNode

Add a new node related to this. Adds a child past the LastChild. Returns a pointer to the new object or NULL if an error occured.

Return type

TiXmlNode

InsertBeforeChild(beforeThis: TiXmlNode, addThis: TiXmlNode) → TiXmlNode

Add a new node related to this. Adds a child before the specified child. Returns a pointer to the new object or NULL if an error occured.

Return type

TiXmlNode

InsertAfterChild(afterThis: TiXmlNode, addThis: TiXmlNode) → TiXmlNode

Add a new node related to this. Adds a child after the specified child. Returns a pointer to the new object or NULL if an error occured.

Return type

TiXmlNode

ReplaceChild(replaceThis: TiXmlNode, withThis: TiXmlNode) → TiXmlNode

Replace a child of this node. Returns a pointer to the new object or NULL if an error occured.

Return type

TiXmlNode

RemoveChild(removeThis: TiXmlNode) → bool

/// Delete a child of this node.

PreviousSibling() → TiXmlNode
Return type

TiXmlNode

PreviousSibling() → TiXmlNode

/// Navigate to a sibling node.

Return type

TiXmlNode

PreviousSibling(_prev: str) → TiXmlNode
Return type

TiXmlNode

PreviousSibling(param0: str) → TiXmlNode

/// Navigate to a sibling node.

Return type

TiXmlNode

PreviousSibling(_value: str) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

PreviousSibling(_value: str) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

NextSibling() → TiXmlNode
Return type

TiXmlNode

NextSibling() → TiXmlNode

/// Navigate to a sibling node.

Return type

TiXmlNode

NextSibling(_next: str) → TiXmlNode
Return type

TiXmlNode

NextSibling(param0: str) → TiXmlNode

/// Navigate to a sibling node with the given ‘value’.

Return type

TiXmlNode

NextSibling(_value: str) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

NextSibling(_value: str) → TiXmlNode

///< STL std::string form.

Return type

TiXmlNode

NextSiblingElement() → TiXmlElement
Return type

TiXmlElement

NextSiblingElement() → TiXmlElement

Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

Return type

TiXmlElement

NextSiblingElement(_next: str) → TiXmlElement
Return type

TiXmlElement

NextSiblingElement(param0: str) → TiXmlElement

Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

Return type

TiXmlElement

NextSiblingElement(_value: str) → TiXmlElement

///< STL std::string form.

Return type

TiXmlElement

NextSiblingElement(_value: str) → TiXmlElement

///< STL std::string form.

Return type

TiXmlElement

FirstChildElement() → TiXmlElement
Return type

TiXmlElement

FirstChildElement() → TiXmlElement

/// Convenience function to get through elements.

Return type

TiXmlElement

FirstChildElement(_value: str) → TiXmlElement
Return type

TiXmlElement

FirstChildElement(_value: str) → TiXmlElement

/// Convenience function to get through elements.

Return type

TiXmlElement

FirstChildElement(_value: str) → TiXmlElement

///< STL std::string form.

Return type

TiXmlElement

FirstChildElement(_value: str) → TiXmlElement

///< STL std::string form.

Return type

TiXmlElement

Type() → int

Query the type (as an enumerated value, above) of this node. The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION.

GetDocument() → TiXmlDocument
Return type

TiXmlDocument

GetDocument() → TiXmlDocument

Return a pointer to the Document this node lives in. Returns null if not in a document.

Return type

TiXmlDocument

NoChildren() → bool

/// Returns true if this node has no children.

ToDocument() → TiXmlDocument

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlDocument

ToDocument() → TiXmlDocument

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlDocument

ToElement() → TiXmlElement

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlElement

ToElement() → TiXmlElement

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlElement

ToComment() → TiXmlComment

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlComment

ToComment() → TiXmlComment

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlComment

ToUnknown() → TiXmlUnknown

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlUnknown

ToUnknown() → TiXmlUnknown

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlUnknown

ToText() → TiXmlText

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlText

ToText() → TiXmlText

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlText

ToDeclaration() → TiXmlDeclaration

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlDeclaration

ToDeclaration() → TiXmlDeclaration

///< Cast to a more defined type. Will return null if not of the requested type.

Return type

TiXmlDeclaration

Clone() → TiXmlNode

Create an exact duplicate of this node and return it. The memory must be deleted by the caller.

Return type

TiXmlNode

Accept(visitor: TiXmlVisitor) → bool

Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface.

This is essentially a SAX interface for TinyXML. (Note however it doesn’t re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.)

The interface has been based on ideas from:

Which are both good references for “visiting”.

An example of using Accept():

TiXmlPrinter printer;
tinyxmlDoc.Accept( &printer );
const char* xmlcstr = printer.CStr();
enum NodeType

The types of XML nodes supported by TinyXml. (All the unsupported types are picked up by UNKNOWN.)

enumerator TINYXML_DOCUMENT = 0
enumerator TINYXML_ELEMENT = 1
enumerator TINYXML_COMMENT = 2
enumerator TINYXML_UNKNOWN = 3
enumerator TINYXML_TEXT = 4
enumerator TINYXML_DECLARATION = 5
enumerator TINYXML_TYPECOUNT = 6