TiXmlNode Class Reference
#include <tinyxml.hh>
Inheritance diagram for TiXmlNode:

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.
Definition at line 387 of file tinyxml.hh.
Public Types
- DOCUMENT
- ELEMENT
- COMMENT
- UNKNOWN
- TEXT
- DECLARATION
- TYPECOUNT
- enum NodeType {
DOCUMENT, ELEMENT, COMMENT, UNKNOWN,
TEXT, DECLARATION, TYPECOUNT
}- The types of XML nodes supported by TinyXml. More...
- The types of XML nodes supported by TinyXml. More...
Public Member Functions
- virtual ~TiXmlNode ()
- const char * Value () const
- The meaning of 'value' changes for the specific type of TiXmlNode.
- The meaning of 'value' changes for the specific type of TiXmlNode.
- const std::string & ValueStr () const
- Return Value() as a std::string.
- Return Value() as a std::string.
- void SetValue (const char *_value)
- void SetValue (const std::string &_value)
- void Clear ()
- TiXmlNode * Parent ()
- const TiXmlNode * Parent () const
- const TiXmlNode * FirstChild () const
- TiXmlNode * FirstChild ()
- const TiXmlNode * FirstChild (const char *value) const
- TiXmlNode * FirstChild (const char *value)
- const TiXmlNode * LastChild () const
- TiXmlNode * LastChild ()
- const TiXmlNode * LastChild (const char *value) const
- TiXmlNode * LastChild (const char *value)
- const TiXmlNode * FirstChild (const std::string &_value) const
- TiXmlNode * FirstChild (const std::string &_value)
- const TiXmlNode * LastChild (const std::string &_value) const
- TiXmlNode * LastChild (const std::string &_value)
- const TiXmlNode * IterateChildren (const TiXmlNode *previous) const
- TiXmlNode * IterateChildren (TiXmlNode *previous)
- const TiXmlNode * IterateChildren (const char *value, const TiXmlNode *previous) const
- TiXmlNode * IterateChildren (const char *value, TiXmlNode *previous)
- const TiXmlNode * IterateChildren (const std::string &_value, const TiXmlNode *previous) const
- TiXmlNode * IterateChildren (const std::string &_value, TiXmlNode *previous)
- TiXmlNode * InsertEndChild (const TiXmlNode &addThis)
- TiXmlNode * LinkEndChild (TiXmlNode *addThis)
- TiXmlNode * InsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis)
- TiXmlNode * InsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis)
- TiXmlNode * ReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis)
- bool RemoveChild (TiXmlNode *removeThis)
- const TiXmlNode * PreviousSibling () const
- TiXmlNode * PreviousSibling ()
- const TiXmlNode * PreviousSibling (const char *) const
- TiXmlNode * PreviousSibling (const char *)
- const TiXmlNode * PreviousSibling (const std::string &_value) const
- TiXmlNode * PreviousSibling (const std::string &_value)
- const TiXmlNode * NextSibling (const std::string &_value) const
- TiXmlNode * NextSibling (const std::string &_value)
- const TiXmlNode * NextSibling () const
- TiXmlNode * NextSibling ()
- const TiXmlNode * NextSibling (const char *) const
- TiXmlNode * NextSibling (const char *)
- const TiXmlElement * NextSiblingElement () const
- TiXmlElement * NextSiblingElement ()
- const TiXmlElement * NextSiblingElement (const char *) const
- TiXmlElement * NextSiblingElement (const char *)
- const TiXmlElement * NextSiblingElement (const std::string &_value) const
- TiXmlElement * NextSiblingElement (const std::string &_value)
- const TiXmlElement * FirstChildElement () const
- TiXmlElement * FirstChildElement ()
- const TiXmlElement * FirstChildElement (const char *value) const
- TiXmlElement * FirstChildElement (const char *value)
- const TiXmlElement * FirstChildElement (const std::string &_value) const
- TiXmlElement * FirstChildElement (const std::string &_value)
- int Type () const
- const TiXmlDocument * GetDocument () const
- TiXmlDocument * GetDocument ()
- bool NoChildren () const
- const TiXmlDocument * ToDocument () const
- const TiXmlElement * ToElement () const
- const TiXmlComment * ToComment () const
- const TiXmlUnknown * ToUnknown () const
- const TiXmlText * ToText () const
- const TiXmlDeclaration * ToDeclaration () const
- TiXmlDocument * ToDocument ()
- TiXmlElement * ToElement ()
- TiXmlComment * ToComment ()
- TiXmlUnknown * ToUnknown ()
- TiXmlText * ToText ()
- TiXmlDeclaration * ToDeclaration ()
- virtual TiXmlNode * Clone () const =0
Protected Member Functions
- TiXmlNode (NodeType _type)
- void CopyTo (TiXmlNode *target) const
- virtual void StreamIn (TIXML_ISTREAM *in, TIXML_STRING *tag)=0
- TiXmlNode * Identify (const char *start, TiXmlEncoding encoding)
Protected Attributes
- TiXmlNode * parent
- NodeType type
- TiXmlNode * firstChild
- TiXmlNode * lastChild
- TIXML_STRING value
- TiXmlNode * prev
- TiXmlNode * next
Friends
- class TiXmlDocument
- class TiXmlElement
- VUTIL_API std::istream & operator>> (std::istream &in, TiXmlNode &base)
- VUTIL_API friend std::ostream & operator<< (std::ostream &out, const TiXmlNode &base)
- VUTIL_API friend std::string & operator<< (std::string &out, const TiXmlNode &base)
Member Enumeration Documentation
| enum TiXmlNode::NodeType |
The types of XML nodes supported by TinyXml.
(All the unsupported types are picked up by UNKNOWN.)
Definition at line 429 of file tinyxml.hh.
Constructor & Destructor Documentation
| virtual TiXmlNode::~TiXmlNode | ( | ) | [virtual] |
| TiXmlNode::TiXmlNode | ( | NodeType | _type | ) | [protected] |
Member Function Documentation
| void TiXmlNode::Clear | ( | ) |
Delete all the children of this node. Does not affect 'this'.
| virtual TiXmlNode* TiXmlNode::Clone | ( | ) | const [pure virtual] |
Create an exact duplicate of this node and return it.
The memory must be deleted by the caller.
Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument.
| void TiXmlNode::CopyTo | ( | TiXmlNode * | target | ) | const [protected] |
| TiXmlNode* TiXmlNode::FirstChild | ( | const std::string & | _value | ) | [inline] |
| const TiXmlNode* TiXmlNode::FirstChild | ( | const std::string & | _value | ) | const [inline] |
| TiXmlNode* TiXmlNode::FirstChild | ( | const char * | value | ) |
The first child of this node with the matching 'value'. Will be null if none found.
| const TiXmlNode* TiXmlNode::FirstChild | ( | const char * | value | ) | const |
The first child of this node with the matching 'value'. Will be null if none found.
| TiXmlNode* TiXmlNode::FirstChild | ( | ) | [inline] |
Definition at line 492 of file tinyxml.hh.
| const TiXmlNode* TiXmlNode::FirstChild | ( | ) | const [inline] |
The first child of this node. Will be null if there are no children.
Definition at line 491 of file tinyxml.hh.
Referenced by FirstChild().
| TiXmlElement* TiXmlNode::FirstChildElement | ( | const std::string & | _value | ) | [inline] |
| const TiXmlElement* TiXmlNode::FirstChildElement | ( | const std::string & | _value | ) | const [inline] |
| TiXmlElement* TiXmlNode::FirstChildElement | ( | const char * | value | ) |
| const TiXmlElement* TiXmlNode::FirstChildElement | ( | const char * | value | ) | const |
Convenience function to get through elements.
| TiXmlElement* TiXmlNode::FirstChildElement | ( | ) |
| const TiXmlElement* TiXmlNode::FirstChildElement | ( | ) | const |
Convenience function to get through elements.
Referenced by FirstChildElement(), and TiXmlDocument::RootElement().
| TiXmlDocument* TiXmlNode::GetDocument | ( | ) |
| const TiXmlDocument* TiXmlNode::GetDocument | ( | ) | const |
Return a pointer to the Document this node lives in.
Returns null if not in a document.
| TiXmlNode* TiXmlNode::Identify | ( | const char * | start, | |
| TiXmlEncoding | encoding | |||
| ) | [protected] |
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.
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.
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.
| const TiXmlNode* TiXmlNode::IterateChildren | ( | const char * | value, | |
| const TiXmlNode * | previous | |||
| ) | const |
This flavor of IterateChildren searches for children with a particular 'value'.
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.
Referenced by IterateChildren().
| TiXmlNode* TiXmlNode::LastChild | ( | const std::string & | _value | ) | [inline] |
| const TiXmlNode* TiXmlNode::LastChild | ( | const std::string & | _value | ) | const [inline] |
| TiXmlNode* TiXmlNode::LastChild | ( | const char * | value | ) |
The last child of this node matching 'value'. Will be null if there are no children.
| const TiXmlNode* TiXmlNode::LastChild | ( | const char * | value | ) | const |
| TiXmlNode* TiXmlNode::LastChild | ( | ) | [inline] |
The last child of this node. Will be null if there are no children.
Definition at line 497 of file tinyxml.hh.
| const TiXmlNode* TiXmlNode::LastChild | ( | ) | const [inline] |
Add a new node related to this.
Adds a child past the LastChild.
NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions.
- See also:
- InsertEndChild
| TiXmlNode* TiXmlNode::NextSibling | ( | const char * | ) |
| const TiXmlNode* TiXmlNode::NextSibling | ( | const char * | ) | const |
Navigate to a sibling node with the given 'value'.
| TiXmlNode* TiXmlNode::NextSibling | ( | ) | [inline] |
Definition at line 588 of file tinyxml.hh.
| const TiXmlNode* TiXmlNode::NextSibling | ( | ) | const [inline] |
| TiXmlNode* TiXmlNode::NextSibling | ( | const std::string & | _value | ) | [inline] |
| const TiXmlNode* TiXmlNode::NextSibling | ( | const std::string & | _value | ) | const [inline] |
| TiXmlElement* TiXmlNode::NextSiblingElement | ( | const std::string & | _value | ) | [inline] |
| const TiXmlElement* TiXmlNode::NextSiblingElement | ( | const std::string & | _value | ) | const [inline] |
| TiXmlElement* TiXmlNode::NextSiblingElement | ( | const char * | ) |
| const TiXmlElement* TiXmlNode::NextSiblingElement | ( | const char * | ) | const |
Convenience function to get through elements.
Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.
| TiXmlElement* TiXmlNode::NextSiblingElement | ( | ) |
| const TiXmlElement* TiXmlNode::NextSiblingElement | ( | ) | const |
Convenience function to get through elements.
Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.
Referenced by NextSiblingElement().
| bool TiXmlNode::NoChildren | ( | ) | const [inline] |
| const TiXmlNode* TiXmlNode::Parent | ( | ) | const [inline] |
Definition at line 489 of file tinyxml.hh.
| TiXmlNode* TiXmlNode::Parent | ( | ) | [inline] |
| TiXmlNode* TiXmlNode::PreviousSibling | ( | const std::string & | _value | ) | [inline] |
| const TiXmlNode* TiXmlNode::PreviousSibling | ( | const std::string & | _value | ) | const [inline] |
| TiXmlNode* TiXmlNode::PreviousSibling | ( | const char * | ) |
| const TiXmlNode* TiXmlNode::PreviousSibling | ( | const char * | ) | const |
Navigate to a sibling node.
| TiXmlNode* TiXmlNode::PreviousSibling | ( | ) | [inline] |
Definition at line 573 of file tinyxml.hh.
| const TiXmlNode* TiXmlNode::PreviousSibling | ( | ) | const [inline] |
Navigate to a sibling node.
Definition at line 572 of file tinyxml.hh.
Referenced by PreviousSibling().
| bool TiXmlNode::RemoveChild | ( | TiXmlNode * | removeThis | ) |
Delete a child of this node.
Replace a child of this node.
Returns a pointer to the new object or NULL if an error occured.
| void TiXmlNode::SetValue | ( | const std::string & | _value | ) | [inline] |
| void TiXmlNode::SetValue | ( | const char * | _value | ) | [inline] |
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
Definition at line 473 of file tinyxml.hh.
Referenced by SetValue(), and TiXmlText::TiXmlText().
| virtual void TiXmlNode::StreamIn | ( | TIXML_ISTREAM * | in, | |
| TIXML_STRING * | tag | |||
| ) | [protected, pure virtual] |
Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument.
| TiXmlComment* TiXmlNode::ToComment | ( | ) | [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 650 of file tinyxml.hh.
| const TiXmlComment* TiXmlNode::ToComment | ( | ) | const [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 643 of file tinyxml.hh.
| TiXmlDeclaration* TiXmlNode::ToDeclaration | ( | ) | [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 653 of file tinyxml.hh.
| const TiXmlDeclaration* TiXmlNode::ToDeclaration | ( | ) | const [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 646 of file tinyxml.hh.
| TiXmlDocument* TiXmlNode::ToDocument | ( | ) | [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 648 of file tinyxml.hh.
| const TiXmlDocument* TiXmlNode::ToDocument | ( | ) | const [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 641 of file tinyxml.hh.
| TiXmlElement* TiXmlNode::ToElement | ( | ) | [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 649 of file tinyxml.hh.
| const TiXmlElement* TiXmlNode::ToElement | ( | ) | const [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 642 of file tinyxml.hh.
| TiXmlText* TiXmlNode::ToText | ( | ) | [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 652 of file tinyxml.hh.
| const TiXmlText* TiXmlNode::ToText | ( | ) | const [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 645 of file tinyxml.hh.
| TiXmlUnknown* TiXmlNode::ToUnknown | ( | ) | [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 651 of file tinyxml.hh.
| const TiXmlUnknown* TiXmlNode::ToUnknown | ( | ) | const [inline] |
Cast to a more defined type. Will return null not of the requested type.
Definition at line 644 of file tinyxml.hh.
| int TiXmlNode::Type | ( | ) | const [inline] |
Query the type (as an enumerated value, above) of this node.
The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION.
Definition at line 630 of file tinyxml.hh.
| const char* TiXmlNode::Value | ( | ) | const [inline] |
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.
Definition at line 454 of file tinyxml.hh.
| const std::string& TiXmlNode::ValueStr | ( | ) | const [inline] |
Return Value() as a std::string.
If you only use STL, this is more efficient than calling Value(). Only available in STL mode.
Definition at line 461 of file tinyxml.hh.
Friends And Related Function Documentation
| VUTIL_API friend std::string& operator<< | ( | std::string & | out, | |
| const TiXmlNode & | base | |||
| ) | [friend] |
Appends the XML node or attribute to a std::string.
| VUTIL_API friend std::ostream& operator<< | ( | std::ostream & | out, | |
| const TiXmlNode & | base | |||
| ) | [friend] |
An output stream operator, for every class.
Note that this outputs without any newlines or formatting, as opposed to Print(), which includes tabs and new lines.
The operator<< and operator>> are not completely symmetric. Writing a node to a stream is very well defined. You'll get a nice stream of output, without any extra whitespace or newlines.
But reading is not as well defined. (As it always is.) If you create a TiXmlElement (for example) and read that from an input stream, the text needs to define an element or junk will result. This is true of all input streams, but it's worth keeping in mind.
A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element.
| VUTIL_API std::istream& operator>> | ( | std::istream & | in, | |
| TiXmlNode & | base | |||
| ) | [friend] |
An input stream operator, for every class.
Tolerant of newlines and formatting, but doesn't expect them.
friend class TiXmlDocument [friend] |
friend class TiXmlElement [friend] |
Reimplemented from TiXmlBase.
Reimplemented in TiXmlText.
Definition at line 390 of file tinyxml.hh.
Member Data Documentation
TiXmlNode* TiXmlNode::firstChild [protected] |
TiXmlNode* TiXmlNode::lastChild [protected] |
TiXmlNode* TiXmlNode::next [protected] |
TiXmlNode* TiXmlNode::parent [protected] |
TiXmlNode* TiXmlNode::prev [protected] |
NodeType TiXmlNode::type [protected] |
Definition at line 676 of file tinyxml.hh.
Referenced by ToComment(), ToDeclaration(), ToDocument(), ToElement(), ToText(), ToUnknown(), and Type().
TIXML_STRING TiXmlNode::value [protected] |
The documentation for this class was generated from the following file:
- /home/tetron/hack/vos/libs/vos/vutil/tinyxml.hh