Panda3D
Public Types | Public Member Functions | List of all members
TiXmlNode Class Reference

The parent class for everything in the Document Object Model. More...

Inheritance diagram for TiXmlNode:
TiXmlBase TiXmlComment TiXmlDeclaration TiXmlDocument TiXmlElement TiXmlText TiXmlUnknown

Public Types

enum  NodeType {
  TINYXML_DOCUMENT = 0, TINYXML_ELEMENT = 1, TINYXML_COMMENT = 2, TINYXML_UNKNOWN = 3,
  TINYXML_TEXT = 4, TINYXML_DECLARATION = 5, TINYXML_TYPECOUNT = 6
}
 The types of XML nodes supported by TinyXml. More...
 
- Public Types inherited from TiXmlBase
enum  {
  TIXML_NO_ERROR = 0, TIXML_ERROR = 1, TIXML_ERROR_OPENING_FILE = 2, TIXML_ERROR_PARSING_ELEMENT = 3,
  TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME = 4, TIXML_ERROR_READING_ELEMENT_VALUE = 5, TIXML_ERROR_READING_ATTRIBUTES = 6, TIXML_ERROR_PARSING_EMPTY = 7,
  TIXML_ERROR_READING_END_TAG = 8, TIXML_ERROR_PARSING_UNKNOWN = 9, TIXML_ERROR_PARSING_COMMENT = 10, TIXML_ERROR_PARSING_DECLARATION = 11,
  TIXML_ERROR_DOCUMENT_EMPTY = 12, TIXML_ERROR_EMBEDDED_NULL = 13, TIXML_ERROR_PARSING_CDATA = 14, TIXML_ERROR_DOCUMENT_TOP_ONLY = 15,
  TIXML_ERROR_STRING_COUNT = 16
}
 

Public Member Functions

bool Accept (TiXmlVisitor visitor)
 Accept a hierchical visit the nodes in the TinyXML DOM. More...
 
 Clear ()
 Delete all the children of this node. Does not affect 'this'. More...
 
TiXmlNode Clone ()
 Create an exact duplicate of this node and return it. More...
 
TiXmlNode FirstChild ()
 The first child of this node. Will be null if there are no children. More...
 
const TiXmlNode FirstChild ()
 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. More...
 
TiXmlNode FirstChild (str _value)
 
const TiXmlNode FirstChild (str value)
 STL std::string form. More...
 
TiXmlNode FirstChild (str _value)
 STL std::string form. More...
 
const TiXmlNode FirstChild (str _value)
 
TiXmlElement FirstChildElement ()
 
const TiXmlElement FirstChildElement ()
 Convenience function to get through elements. More...
 
TiXmlElement FirstChildElement (str _value)
 
const TiXmlElement FirstChildElement (str _value)
 Convenience function to get through elements. More...
 
TiXmlElement FirstChildElement (str _value)
 STL std::string form. More...
 
const TiXmlElement FirstChildElement (str _value)
 
TiXmlDocument GetDocument ()
 
const TiXmlDocument GetDocument ()
 Return a pointer to the Document this node lives in. More...
 
TiXmlNode InsertAfterChild (TiXmlNode afterThis, const TiXmlNode addThis)
 Add a new node related to this. More...
 
TiXmlNode InsertBeforeChild (TiXmlNode beforeThis, const TiXmlNode addThis)
 Add a new node related to this. More...
 
TiXmlNode InsertEndChild (const TiXmlNode addThis)
 Add a new node related to this. More...
 
TiXmlNode IterateChildren (const TiXmlNode previous)
 
const TiXmlNode IterateChildren (const TiXmlNode previous)
 An alternate way to walk the children of a node. More...
 
TiXmlNode IterateChildren (str _value, const TiXmlNode previous)
 
const TiXmlNode IterateChildren (str value, const TiXmlNode previous)
 This flavor of IterateChildren searches for children with a particular 'value'. More...
 
TiXmlNode IterateChildren (str _value, const TiXmlNode previous)
 STL std::string form. More...
 
const TiXmlNode IterateChildren (str _value, const TiXmlNode previous)
 
TiXmlNode LastChild ()
 The last child of this node. Will be null if there are no children. More...
 
const TiXmlNode LastChild ()
 The last child of this node. Will be null if there are no children. More...
 
TiXmlNode LastChild (str _value)
 The last child of this node matching 'value'. Will be null if there are no children. More...
 
const TiXmlNode LastChild (str value)
 The last child of this node matching 'value'. Will be null if there are no children. More...
 
TiXmlNode LastChild (str _value)
 STL std::string form. More...
 
const TiXmlNode LastChild (str _value)
 
TiXmlNode NextSibling ()
 
const TiXmlNode NextSibling ()
 Navigate to a sibling node. More...
 
TiXmlNode NextSibling (str _next)
 
const TiXmlNode NextSibling (str)
 Navigate to a sibling node with the given 'value'. More...
 
TiXmlNode NextSibling (str _value)
 STL std::string form. More...
 
const TiXmlNode NextSibling (str _value)
 
TiXmlElement NextSiblingElement ()
 
const TiXmlElement NextSiblingElement ()
 Convenience function to get through elements. More...
 
TiXmlElement NextSiblingElement (str _next)
 
const TiXmlElement NextSiblingElement (str)
 Convenience function to get through elements. More...
 
TiXmlElement NextSiblingElement (str _value)
 STL std::string form. More...
 
const TiXmlElement NextSiblingElement (str _value)
 
bool NoChildren ()
 Returns true if this node has no children. More...
 
TiXmlNode Parent ()
 One step up the DOM. More...
 
const TiXmlNode Parent ()
 The first child of this node. Will be null if there are no children. More...
 
TiXmlNode PreviousSibling ()
 
const TiXmlNode PreviousSibling ()
 Navigate to a sibling node. More...
 
TiXmlNode PreviousSibling (str _prev)
 
const TiXmlNode PreviousSibling (str)
 Navigate to a sibling node. More...
 
TiXmlNode PreviousSibling (str _value)
 STL std::string form. More...
 
const TiXmlNode PreviousSibling (str _value)
 
bool RemoveChild (TiXmlNode removeThis)
 Delete a child of this node. More...
 
TiXmlNode ReplaceChild (TiXmlNode replaceThis, const TiXmlNode withThis)
 Replace a child of this node. More...
 
 SetValue (str _value)
 Changes the value of the node. More...
 
 SetValue (str _value)
 STL std::string form. More...
 
TiXmlComment ToComment ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlComment ToComment ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
TiXmlDeclaration ToDeclaration ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlDeclaration ToDeclaration ()
 
TiXmlDocument ToDocument ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlDocument ToDocument ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
TiXmlElement ToElement ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlElement ToElement ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
TiXmlText ToText ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlText ToText ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
TiXmlUnknown ToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
const TiXmlUnknown ToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
int Type ()
 Query the type (as an enumerated value, above) of this node. More...
 
str Value ()
 The meaning of 'value' changes for the specific type of TiXmlNode. More...
 
str ValueStr ()
 Return Value() as a std::string. More...
 
str ValueTStr ()
 
- Public Member Functions inherited from TiXmlBase
int Column ()
 Get a pointer to arbitrary user data. More...
 
 GetUserData ()
 Get a pointer to arbitrary user data. More...
 
 GetUserData ()
 
str Parse (str p, TiXmlParsingData data, TiXmlEncoding encoding)
 
 Print (FILE cfile, int depth)
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.) Either or both cfile and str can be null. More...
 
int Row ()
 Return the position, in the original source file, of this node or attribute. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from TiXmlBase
static bool IsWhiteSpaceCondensed ()
 Return the current white space setting. More...
 
static SetCondenseWhiteSpace (bool condense)
 The world does not agree on whether white space should be kept or not. More...
 

Detailed Description

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.

Member Enumeration Documentation

◆ NodeType

enum NodeType

The types of XML nodes supported by TinyXml.

(All the unsupported types are picked up by UNKNOWN.)

Enumerator
TINYXML_DOCUMENT 
TINYXML_ELEMENT 
TINYXML_COMMENT 
TINYXML_UNKNOWN 
TINYXML_TEXT 
TINYXML_DECLARATION 
TINYXML_TYPECOUNT 

Member Function Documentation

◆ Accept()

bool Accept ( TiXmlVisitor  visitor)

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

Clear ( )

Delete all the children of this node. Does not affect 'this'.

◆ Clone()

TiXmlNode Clone ( )

Create an exact duplicate of this node and return it.

The memory must be deleted by the caller.

◆ FirstChild() [1/6]

TiXmlNode FirstChild ( )

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

◆ FirstChild() [2/6]

const TiXmlNode FirstChild ( )

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() [3/6]

TiXmlNode FirstChild ( str  _value)

◆ FirstChild() [4/6]

const TiXmlNode FirstChild ( str  value)

STL std::string form.

◆ FirstChild() [5/6]

TiXmlNode FirstChild ( str  _value)

STL std::string form.

◆ FirstChild() [6/6]

const TiXmlNode FirstChild ( str  _value)

◆ FirstChildElement() [1/6]

TiXmlElement FirstChildElement ( )

◆ FirstChildElement() [2/6]

const TiXmlElement FirstChildElement ( )

Convenience function to get through elements.

◆ FirstChildElement() [3/6]

TiXmlElement FirstChildElement ( str  _value)

◆ FirstChildElement() [4/6]

const TiXmlElement FirstChildElement ( str  _value)

Convenience function to get through elements.

STL std::string form.

◆ FirstChildElement() [5/6]

TiXmlElement FirstChildElement ( str  _value)

STL std::string form.

◆ FirstChildElement() [6/6]

const TiXmlElement FirstChildElement ( str  _value)

◆ GetDocument() [1/2]

TiXmlDocument GetDocument ( )

◆ GetDocument() [2/2]

const TiXmlDocument GetDocument ( )

Return a pointer to the Document this node lives in.

Returns null if not in a document.

◆ InsertAfterChild()

TiXmlNode InsertAfterChild ( TiXmlNode  afterThis,
const TiXmlNode  addThis 
)

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

TiXmlNode InsertBeforeChild ( TiXmlNode  beforeThis,
const TiXmlNode  addThis 
)

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

TiXmlNode InsertEndChild ( const TiXmlNode  addThis)

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() [1/6]

TiXmlNode IterateChildren ( const TiXmlNode  previous)

◆ IterateChildren() [2/6]

const TiXmlNode IterateChildren ( const TiXmlNode  previous)

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() [3/6]

TiXmlNode IterateChildren ( str  _value,
const TiXmlNode  previous 
)

◆ IterateChildren() [4/6]

const TiXmlNode IterateChildren ( str  value,
const TiXmlNode  previous 
)

This flavor of IterateChildren searches for children with a particular 'value'.

STL std::string form.

◆ IterateChildren() [5/6]

TiXmlNode IterateChildren ( str  _value,
const TiXmlNode  previous 
)

STL std::string form.

◆ IterateChildren() [6/6]

const TiXmlNode IterateChildren ( str  _value,
const TiXmlNode  previous 
)

◆ LastChild() [1/6]

TiXmlNode LastChild ( )

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

◆ LastChild() [2/6]

const TiXmlNode LastChild ( )

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

◆ LastChild() [3/6]

TiXmlNode LastChild ( str  _value)

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

◆ LastChild() [4/6]

const TiXmlNode LastChild ( str  value)

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

STL std::string form.

◆ LastChild() [5/6]

TiXmlNode LastChild ( str  _value)

STL std::string form.

◆ LastChild() [6/6]

const TiXmlNode LastChild ( str  _value)

◆ NextSibling() [1/6]

TiXmlNode NextSibling ( )

◆ NextSibling() [2/6]

const TiXmlNode NextSibling ( )

Navigate to a sibling node.

◆ NextSibling() [3/6]

TiXmlNode NextSibling ( str  _next)

◆ NextSibling() [4/6]

const TiXmlNode NextSibling ( str  )

Navigate to a sibling node with the given 'value'.

STL std::string form.

◆ NextSibling() [5/6]

TiXmlNode NextSibling ( str  _value)

STL std::string form.

◆ NextSibling() [6/6]

const TiXmlNode NextSibling ( str  _value)

◆ NextSiblingElement() [1/6]

TiXmlElement NextSiblingElement ( )

◆ NextSiblingElement() [2/6]

const TiXmlElement NextSiblingElement ( )

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() [3/6]

TiXmlElement NextSiblingElement ( str  _next)

◆ NextSiblingElement() [4/6]

const TiXmlElement NextSiblingElement ( str  )

Convenience function to get through elements.

Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.STL std::string form.

◆ NextSiblingElement() [5/6]

TiXmlElement NextSiblingElement ( str  _value)

STL std::string form.

◆ NextSiblingElement() [6/6]

const TiXmlElement NextSiblingElement ( str  _value)

◆ NoChildren()

bool NoChildren ( )

Returns true if this node has no children.

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

◆ Parent() [1/2]

TiXmlNode Parent ( )

One step up the DOM.

◆ Parent() [2/2]

const TiXmlNode Parent ( )

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

◆ PreviousSibling() [1/6]

TiXmlNode PreviousSibling ( )

◆ PreviousSibling() [2/6]

const TiXmlNode PreviousSibling ( )

Navigate to a sibling node.

◆ PreviousSibling() [3/6]

TiXmlNode PreviousSibling ( str  _prev)

◆ PreviousSibling() [4/6]

const TiXmlNode PreviousSibling ( str  )

Navigate to a sibling node.

STL std::string form.

◆ PreviousSibling() [5/6]

TiXmlNode PreviousSibling ( str  _value)

STL std::string form.

◆ PreviousSibling() [6/6]

const TiXmlNode PreviousSibling ( str  _value)

◆ RemoveChild()

bool RemoveChild ( TiXmlNode  removeThis)

Delete a child of this node.

◆ ReplaceChild()

TiXmlNode ReplaceChild ( TiXmlNode  replaceThis,
const TiXmlNode  withThis 
)

Replace a child of this node.

Returns a pointer to the new object or NULL if an error occured.

◆ SetValue() [1/2]

SetValue ( str  _value)

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() [2/2]

SetValue ( str  _value)

STL std::string form.

◆ ToComment() [1/2]

TiXmlComment ToComment ( )

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

◆ ToComment() [2/2]

const TiXmlComment ToComment ( )

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

◆ ToDeclaration() [1/2]

TiXmlDeclaration ToDeclaration ( )

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

◆ ToDeclaration() [2/2]

const TiXmlDeclaration ToDeclaration ( )

◆ ToDocument() [1/2]

TiXmlDocument ToDocument ( )

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

◆ ToDocument() [2/2]

const TiXmlDocument ToDocument ( )

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

◆ ToElement() [1/2]

TiXmlElement ToElement ( )

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

◆ ToElement() [2/2]

const TiXmlElement ToElement ( )

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

◆ ToText() [1/2]

TiXmlText ToText ( )

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

◆ ToText() [2/2]

const TiXmlText ToText ( )

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

◆ ToUnknown() [1/2]

TiXmlUnknown ToUnknown ( )

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

◆ ToUnknown() [2/2]

const TiXmlUnknown ToUnknown ( )

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

◆ Type()

int Type ( )

Query the type (as an enumerated value, above) of this node.

The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION.

◆ Value()

str Value ( )

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 ValueStr ( )

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 ValueTStr ( )