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
-
virtual bool Accept(TiXmlVisitor *visitor) const = 0
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();
-
void Clear(void)
/// Delete all the children of this node. Does not affect ‘this’.
-
virtual TiXmlNode *Clone(void) const = 0
Create an exact duplicate of this node and return it. The memory must be deleted by the caller.
-
TiXmlNode *FirstChild(std::string const &_value)
///< The first child of this node. Will be null if there are no children.
///< The first child of this node. Will be null if there are no children.
///< 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.
///< STL std::string form.
///< STL std::string form.
-
TiXmlElement const *FirstChildElement(void) const
-
TiXmlElement *FirstChildElement(void)
-
TiXmlElement const *FirstChildElement(char const *_value) const
-
TiXmlElement *FirstChildElement(char const *_value)
-
TiXmlElement const *FirstChildElement(std::string const &_value) const
-
TiXmlElement *FirstChildElement(std::string const &_value)
/// Convenience function to get through elements.
/// Convenience function to get through elements.
///< STL std::string form.
///< STL std::string form.
-
TiXmlDocument const *GetDocument(void) const
-
TiXmlDocument *GetDocument(void)
Return a pointer to the Document this node lives in. Returns null if not in a document.
-
TiXmlNode *InsertAfterChild(TiXmlNode *afterThis, TiXmlNode const &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.
-
TiXmlNode *InsertBeforeChild(TiXmlNode *beforeThis, TiXmlNode const &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.
-
TiXmlNode *InsertEndChild(TiXmlNode const &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.
-
TiXmlNode *IterateChildren(std::string const &_value, TiXmlNode const *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.
This flavor of IterateChildren searches for children with a particular ‘value’
STL std::string form.
STL std::string form.
-
TiXmlNode *LastChild(std::string const &_value)
/// The last child of this node. Will be null if there are no children.
/// The last child of this node. Will be null if there are no children.
/// The last child of this node matching ‘value’. Will be null if there are no children.
/// The last child of this node matching ‘value’. Will be null if there are no children.
///< STL std::string form.
///< STL std::string form.
-
TiXmlNode *NextSibling(char const *_next)
///< STL std::string form.
///< STL std::string form.
/// Navigate to a sibling node.
/// Navigate to a sibling node with the given ‘value’.
-
TiXmlElement const *NextSiblingElement(void) const
-
TiXmlElement *NextSiblingElement(void)
-
TiXmlElement const *NextSiblingElement(char const*) const
-
TiXmlElement *NextSiblingElement(char const *_next)
-
TiXmlElement const *NextSiblingElement(std::string const &_value) const
-
TiXmlElement *NextSiblingElement(std::string const &_value)
Convenience function to get through elements. Calls
NextSibling
andToElement
. Will skip all non-Element nodes. Returns 0 if there is not another element.Convenience function to get through elements. Calls
NextSibling
andToElement
. Will skip all non-Element nodes. Returns 0 if there is not another element.STL std::string form.
STL std::string form.
-
bool NoChildren(void) const
/// 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
-
enumerator TINYXML_DOCUMENT = 0
-
TiXmlNode *PreviousSibling(std::string const &_value)
/// Navigate to a sibling node.
/// Navigate to a sibling node.
///< STL std::string form.
///< STL std::string form.
-
TiXmlNode *ReplaceChild(TiXmlNode *replaceThis, TiXmlNode const &withThis)
Replace a child of this node. Returns a pointer to the new object or NULL if an error occured.
-
void SetValue(char const *_value)
-
void SetValue(std::string const &_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
STL std::string form.
-
virtual TiXmlComment const *ToComment(void) const
-
virtual TiXmlComment *ToComment(void)
///< Cast to a more defined type. Will return null if not of the requested type.
-
virtual TiXmlDeclaration const *ToDeclaration(void) const
-
virtual TiXmlDeclaration *ToDeclaration(void)
///< Cast to a more defined type. Will return null if not of the requested type.
-
virtual TiXmlDocument const *ToDocument(void) const
-
virtual TiXmlDocument *ToDocument(void)
///< Cast to a more defined type. Will return null if not of the requested type.
-
virtual TiXmlElement const *ToElement(void) const
-
virtual TiXmlElement *ToElement(void)
///< Cast to a more defined type. Will return null if not of the requested type.
-
virtual TiXmlText *ToText(void)
///< Cast to a more defined type. Will return null if not of the requested type.
-
virtual TiXmlUnknown const *ToUnknown(void) const
-
virtual TiXmlUnknown *ToUnknown(void)
///< Cast to a more defined type. Will return null if not of the requested type.
-
int Type(void) const
Query the type (as an enumerated value, above) of this node. The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION.
-
char const *Value(void) const
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.
-
std::string const &ValueStr(void) const
Return
Value()
as a std::string. If you only use STL, this is more efficient than callingValue()
. Only available in STL mode.
-
std::string const &ValueTStr(void) const
-
virtual bool Accept(TiXmlVisitor *visitor) const = 0