XMLNode is a base class for every object that is in the XML Document Object Model (DOM), except XMLAttributes. Nodes have siblings, a parent, and children which can be navigated. A node is always in a XMLDocument. The type of a XMLNode can be queried, and it can be cast to its more defined type. A XMLDocument allocates memory for all its Nodes. When the XMLDocument gets deleted, all its Nodes will also be deleted.
Class XMLNode
#include <Geode/cocos/support/tinyxml2/tinyxml2.h>
Examples0
Public static methods0
Public member functions45
tinyxml2::XMLDocumentconst*GetDocument()const
/// Get the XMLDocument that owns this XMLNode.
tinyxml2::XMLDocument*GetDocument()
/// Get the XMLDocument that owns this XMLNode.
virtualtinyxml2::XMLElement*ToElement()
/// Safely cast to an Element, or null.
virtualtinyxml2::XMLText*ToText()
/// Safely cast to Text, or null.
virtualtinyxml2::XMLComment*ToComment()
/// Safely cast to a Comment, or null.
virtualtinyxml2::XMLDocument*ToDocument()
/// Safely cast to a Document, or null.
virtualtinyxml2::XMLDeclaration*ToDeclaration()
/// Safely cast to a Declaration, or null.
virtualtinyxml2::XMLUnknown*ToUnknown()
/// Safely cast to an Unknown, or null.
virtualtinyxml2::XMLElementconst*ToElement()const
virtualtinyxml2::XMLTextconst*ToText()const
virtualtinyxml2::XMLCommentconst*ToComment()const
virtualtinyxml2::XMLDocumentconst*ToDocument()const
virtualtinyxml2::XMLDeclarationconst*ToDeclaration()const
virtualtinyxml2::XMLUnknownconst*ToUnknown()const
charconst*Value()const
The meaning of ‘value’ changes for the specific type.
voidSetValue(charconst*val,boolstaticMem)
Set the Value of an XML node.
tinyxml2::XMLNodeconst*Parent()const
/// Get the parent of this node on the DOM.
tinyxml2::XMLNode*Parent()
boolNoChildren()const
/// Returns true if this node has no children.
tinyxml2::XMLNodeconst*FirstChild()const
/// Get the first child node, or null if none exists.
tinyxml2::XMLNode*FirstChild()
tinyxml2::XMLElementconst*FirstChildElement(charconst*value)const
Get the first child element, or optionally the first child element with the specified name.
tinyxml2::XMLElement*FirstChildElement(charconst*value)
tinyxml2::XMLNodeconst*LastChild()const
/// Get the last child node, or null if none exists.
tinyxml2::XMLNode*LastChild()
tinyxml2::XMLElementconst*LastChildElement(charconst*value)const
Get the last child element or optionally the last child element with the specified name.
tinyxml2::XMLElement*LastChildElement(charconst*value)
tinyxml2::XMLNodeconst*PreviousSibling()const
/// Get the previous (left) sibling node of this node.
tinyxml2::XMLNode*PreviousSibling()
tinyxml2::XMLElementconst*PreviousSiblingElement(charconst*value)const
/// Get the previous (left) sibling element of this node, with an opitionally supplied name.
tinyxml2::XMLElement*PreviousSiblingElement(charconst*value)
tinyxml2::XMLNodeconst*NextSibling()const
/// Get the next (right) sibling node of this node.
tinyxml2::XMLNode*NextSibling()
tinyxml2::XMLElementconst*NextSiblingElement(charconst*value)const
/// Get the next (right) sibling element of this node, with an opitionally supplied name.
tinyxml2::XMLElement*NextSiblingElement(charconst*value)
tinyxml2::XMLNode*InsertEndChild(tinyxml2::XMLNode*addThis)
Add a child node as the last (right) child.
tinyxml2::XMLNode*LinkEndChild(tinyxml2::XMLNode*addThis)
tinyxml2::XMLNode*InsertFirstChild(tinyxml2::XMLNode*addThis)
Add a child node as the first (left) child.
tinyxml2::XMLNode*InsertAfterChild(tinyxml2::XMLNode*afterThis,tinyxml2::XMLNode*addThis)
Add a node after the specified child node.
voidDeleteChildren()
Delete all the children of this node.
voidDeleteChild()
Delete a child of this node.
virtualtinyxml2::XMLNode*ShallowClone(tinyxml2::XMLDocument*document)const=0
Make a copy of this node, but not its children. You may pass in a Document pointer that will be the owner of the new Node. If the ‘document’ is null, then the node returned will be allocated from the current Document. (this->GetDocument()) Note: if called on a XMLDocument, this will return null.
virtualboolShallowEqual(tinyxml2::XMLNodeconst*compare)const=0
Test if 2 nodes are the same, but don’t test children. The 2 nodes do not need to be in the same Document. Note: if called on a XMLDocument, this will return false.
virtualboolAccept(tinyxml2::XMLVisitor*visitor)const=0
Accept a hierarchical visit of 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:
- http://www.saxproject.org/
- http://c2.com/cgi/wiki?HierarchicalVisitorPattern Which are both good references for “visiting”. An example of using Accept():