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

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();
Clear()None

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

Clone()TiXmlNode

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

FirstChild()TiXmlNode

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

FirstChild()TiXmlNode

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

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.

FirstChild(value: str)TiXmlNode
FirstChild(_value: str)TiXmlNode

///< STL std::string form.

FirstChild(_value: str)TiXmlNode

///< STL std::string form.

FirstChildElement()TiXmlElement
FirstChildElement()TiXmlElement

/// Convenience function to get through elements.

FirstChildElement(_value: str)TiXmlElement
FirstChildElement(_value: str)TiXmlElement

/// Convenience function to get through elements.

FirstChildElement(_value: str)TiXmlElement

///< STL std::string form.

FirstChildElement(_value: str)TiXmlElement

///< STL std::string form.

GetDocument()TiXmlDocument
GetDocument()TiXmlDocument

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

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.

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.

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.

IterateChildren(previous: TiXmlNode)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.

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

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

IterateChildren(_value: str, previous: TiXmlNode)TiXmlNode

///< STL std::string form.

IterateChildren(_value: str, previous: TiXmlNode)TiXmlNode

///< STL std::string form.

LastChild()TiXmlNode

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

LastChild()TiXmlNode

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

LastChild(_value: str)TiXmlNode

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

LastChild(value: str)TiXmlNode

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

LastChild(_value: str)TiXmlNode

///< STL std::string form.

LastChild(_value: str)TiXmlNode

///< STL std::string form.

NextSibling()TiXmlNode
NextSibling()TiXmlNode

/// Navigate to a sibling node.

NextSibling(_next: str)TiXmlNode
NextSibling(param0: str)TiXmlNode

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

NextSibling(_value: str)TiXmlNode

///< STL std::string form.

NextSibling(_value: str)TiXmlNode

///< STL std::string form.

NextSiblingElement()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.

NextSiblingElement(_next: str)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.

NextSiblingElement(_value: str)TiXmlElement

///< STL std::string form.

NextSiblingElement(_value: str)TiXmlElement

///< STL std::string form.

NoChildren()bool

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

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
Parent()TiXmlNode

/// One step up the DOM.

Parent()TiXmlNode
PreviousSibling()TiXmlNode
PreviousSibling()TiXmlNode

/// Navigate to a sibling node.

PreviousSibling(_prev: str)TiXmlNode
PreviousSibling(param0: str)TiXmlNode

/// Navigate to a sibling node.

PreviousSibling(_value: str)TiXmlNode

///< STL std::string form.

PreviousSibling(_value: str)TiXmlNode

///< STL std::string form.

RemoveChild(removeThis: TiXmlNode)bool

/// Delete a child of this node.

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.

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.

ToComment()TiXmlComment

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

ToComment()TiXmlComment

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

ToDeclaration()TiXmlDeclaration

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

ToDeclaration()TiXmlDeclaration

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

ToDocument()TiXmlDocument

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

ToDocument()TiXmlDocument

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

ToElement()TiXmlElement

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

ToElement()TiXmlElement

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

ToText()TiXmlText

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

ToText()TiXmlText

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

ToUnknown()TiXmlUnknown

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

ToUnknown()TiXmlUnknown

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

Type()int

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

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