TiXmlNode Class Reference
[XML objects]

#include <TinyXML.h>

Inherits TiXmlBase, and DigitalSpaces::DIXMLNode1.

Inherited by TiXmlComment, TiXmlDeclaration, TiXmlDocument, TiXmlElement, TiXmlText, and TiXmlUnknown.


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.


Public Types

enum  NodeType {
  DOCUMENT, ELEMENT, COMMENT, UNKNOWN,
  TEXT, DECLARATION, TYPECOUNT
}
 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.
void SetValue (const char *_value)
 Changes the value of the node.
void Clear ()
 Delete all the children of this node. Does not affect 'this'.
TiXmlNodeParent () const
 One step up the DOM.
TiXmlNodeFirstChild () const
 The first child of this node. Will be null if there are no children.
TiXmlNodeFirstChild (const char *value) const
 The first child of this node with the matching 'value'. Will be null if none found.
TiXmlNodeLastChild () const
TiXmlNodeLastChild (const char *value) const
 The last child of this node. Will be null if there are no children.
TiXmlNodeIterateChildren (TiXmlNode *previous) const
 The last child of this node matching 'value'. Will be null if there are no children.
TiXmlNodeIterateChildren (const char *value, TiXmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'.
TiXmlNodeInsertEndChild (const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeLinkEndChild (TiXmlNode *addThis)
 Add a new node related to this.
TiXmlNodeInsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeInsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis)
 Replace a child of this node.
bool RemoveChild (TiXmlNode *removeThis)
 Delete a child of this node.
TiXmlNodePreviousSibling () const
 Navigate to a sibling node.
TiXmlNodePreviousSibling (const char *) const
 Navigate to a sibling node.
TiXmlNodeNextSibling () const
 Navigate to a sibling node.
TiXmlNodeNextSibling (const char *) const
 Navigate to a sibling node with the given 'value'.
TiXmlElementNextSiblingElement () const
 Convenience function to get through elements.
TiXmlElementNextSiblingElement (const char *) const
 Convenience function to get through elements.
TiXmlElementFirstChildElement () const
 Convenience function to get through elements.
TiXmlElementFirstChildElement (const char *value) const
 Convenience function to get through elements.
virtual int Type () const
 Query the type (as an enumerated value, above) of this node.
TiXmlDocumentGetDocument () const
 Return a pointer to the Document this node lives in.
bool NoChildren () const
 Returns true if this node has no children.
TiXmlDocumentToDocument () const
 Cast to a more defined type. Will return null not of the requested type.
TiXmlElementToElement () const
 Cast to a more defined type. Will return null not of the requested type.
TiXmlCommentToComment () const
 Cast to a more defined type. Will return null not of the requested type.
TiXmlUnknownToUnknown () const
 Cast to a more defined type. Will return null not of the requested type.
TiXmlTextToText () const
 Cast to a more defined type. Will return null not of the requested type.
TiXmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlNodeClone () const =0
const char * GetValue ()
 DSS Integration.
DigitalSpaces::DIXMLNode1GetParent ()
 One step up the DOM.
DigitalSpaces::DIXMLNode1GetFirstChild ()
 The first child of this node. Will be null if there are no children.
DigitalSpaces::DIXMLNode1GetFirstChild (const char *value)
 The first child of this node with the matching 'value'. Will be null if none found.
DigitalSpaces::DIXMLNode1GetLastChild ()
 The last child of this node. Will be null if there are no children.
DigitalSpaces::DIXMLNode1GetLastChild (const char *value)
 The last child of this node matching 'value'. Will be null if there are no children.
DigitalSpaces::DIXMLNode1_IterateChildren (DigitalSpaces::DIXMLNode1 *previous)
 The last child of this node matching 'value'. Will be null if there are no children.
DigitalSpaces::DIXMLNode1_IterateChildren (const char *value, DigitalSpaces::DIXMLNode1 *previous)
 This flavor of IterateChildren searches for children with a particular 'value'.
DigitalSpaces::DIXMLNode1InsertEndChild (const DigitalSpaces::DIXMLNode1 *addThis)
 Add a new node related to this.
DigitalSpaces::DIXMLNode1_LinkEndChild (DigitalSpaces::DIXMLNode1 *addThis)
 Add a new node related to this.
DigitalSpaces::DIXMLNode1InsertBeforeChild (DigitalSpaces::DIXMLNode1 *beforeThis, const DigitalSpaces::DIXMLNode1 *addThis)
 Add a new node related to this.
DigitalSpaces::DIXMLNode1InsertAfterChild (DigitalSpaces::DIXMLNode1 *afterThis, const DigitalSpaces::DIXMLNode1 *addThis)
 Add a new node related to this.
DigitalSpaces::DIXMLNode1ReplaceChild (DigitalSpaces::DIXMLNode1 *replaceThis, const DigitalSpaces::DIXMLNode1 *withThis)
 Replace a child of this node.
bool RemoveChild (DigitalSpaces::DIXMLNode1 *removeThis)
 Delete a child of this node.
DigitalSpaces::DIXMLNode1GetPreviousSibling ()
 Navigate to a sibling node.
DigitalSpaces::DIXMLNode1GetPreviousSibling (const char *name)
 Navigate to a sibling node.
DigitalSpaces::DIXMLNode1GetNextSibling ()
 Navigate to a sibling node.
DigitalSpaces::DIXMLNode1GetNextSibling (const char *name)
 Navigate to a sibling node with the given 'value'.
DigitalSpaces::DIXMLElement1GetNextSiblingElement ()
 Convenience function to get through elements.
DigitalSpaces::DIXMLElement1GetNextSiblingElement (const char *name)
 Convenience function to get through elements.
DigitalSpaces::DIXMLElement1GetFirstChildElement ()
 Convenience function to get through elements.
DigitalSpaces::DIXMLElement1GetFirstChildElement (const char *value)
 Convenience function to get through elements.
DigitalSpaces::XMLNodeType Type ()
 Query the type (as an enumerated value, above) of this node.
bool NoChildren ()
 Return a pointer to the Document this node lives in.
DigitalSpaces::DIXMLNode1DoClone ()

Protected Member Functions

 TiXmlNode (NodeType _type)
TiXmlNodeIdentify (const char *start)
void CopyToClone (TiXmlNode *target) const
const TiXmlString & SValue () const

Protected Attributes

TiXmlNodeparent
NodeType type
TiXmlNodefirstChild
TiXmlNodelastChild
TiXmlString value
TiXmlNodeprev
TiXmlNodenext

Private Member Functions

 TiXmlNode (const TiXmlNode &)
void operator= (const TiXmlNode &base)

Friends

class TiXmlDocument
class TiXmlElement
TiXmlOutStream & operator<< (TiXmlOutStream &out, const TiXmlNode &base)

Member Enumeration Documentation

The types of XML nodes supported by TinyXml.

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

Enumerator:
DOCUMENT 
ELEMENT 
COMMENT 
UNKNOWN 
TEXT 
DECLARATION 
TYPECOUNT 


Constructor & Destructor Documentation

virtual TiXmlNode::~TiXmlNode (  )  [virtual]

TiXmlNode::TiXmlNode ( NodeType  _type  )  [protected]

TiXmlNode::TiXmlNode ( const TiXmlNode  )  [private]


Member Function Documentation

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.

Referenced by GetValue().

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
		

Reimplemented from DigitalSpaces::DIXMLNode1.

Referenced by CopyToClone(), and TiXmlText::TiXmlText().

void TiXmlNode::Clear (  ) 

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

Reimplemented from DigitalSpaces::DIXMLNode1.

TiXmlNode* TiXmlNode::Parent (  )  const [inline]

One step up the DOM.

Referenced by GetParent().

TiXmlNode* TiXmlNode::FirstChild (  )  const [inline]

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

Referenced by GetFirstChild().

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::LastChild (  )  const [inline]

Referenced by GetLastChild().

TiXmlNode* TiXmlNode::LastChild ( const char *  value  )  const

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

TiXmlNode* TiXmlNode::IterateChildren ( TiXmlNode previous  )  const

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

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::IterateChildren ( const char *  value,
TiXmlNode previous 
) const

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

TiXmlNode* 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.

Referenced by InsertEndChild().

TiXmlNode* TiXmlNode::LinkEndChild ( TiXmlNode addThis  ) 

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

Referenced by _LinkEndChild().

TiXmlNode* 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.

Referenced by InsertBeforeChild().

TiXmlNode* 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.

Referenced by InsertAfterChild().

TiXmlNode* 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.

Referenced by ReplaceChild().

bool TiXmlNode::RemoveChild ( TiXmlNode removeThis  ) 

Delete a child of this node.

Referenced by RemoveChild().

TiXmlNode* TiXmlNode::PreviousSibling (  )  const [inline]

Navigate to a sibling node.

Referenced by GetPreviousSibling().

TiXmlNode* TiXmlNode::PreviousSibling ( const char *   )  const

Navigate to a sibling node.

TiXmlNode* TiXmlNode::NextSibling (  )  const [inline]

Navigate to a sibling node.

Referenced by GetNextSibling().

TiXmlNode* TiXmlNode::NextSibling ( const char *   )  const

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

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.

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::FirstChildElement (  )  const

Convenience function to get through elements.

Referenced by TiXmlDocument::RootElement().

TiXmlElement* TiXmlNode::FirstChildElement ( const char *  value  )  const

Convenience function to get through elements.

virtual int TiXmlNode::Type (  )  const [inline, virtual]

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

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

TiXmlDocument* TiXmlNode::GetDocument (  )  const

Return a pointer to the Document this node lives in.

Returns null if not in a document.

bool TiXmlNode::NoChildren (  )  const [inline]

Returns true if this node has no children.

TiXmlDocument* TiXmlNode::ToDocument (  )  const [inline]

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

TiXmlElement* TiXmlNode::ToElement (  )  const [inline]

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

Referenced by TiXmlHandle::Element().

TiXmlComment* TiXmlNode::ToComment (  )  const [inline]

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

TiXmlUnknown* TiXmlNode::ToUnknown (  )  const [inline]

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

Referenced by TiXmlHandle::Unknown().

TiXmlText* TiXmlNode::ToText (  )  const [inline]

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

Referenced by TiXmlHandle::Text().

TiXmlDeclaration* TiXmlNode::ToDeclaration (  )  const [inline]

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

virtual TiXmlNode* TiXmlNode::Clone (  )  const [pure virtual]

const char* TiXmlNode::GetValue (  )  [inline]

DSS Integration.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetParent (  )  [inline]

One step up the DOM.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetFirstChild (  )  [inline]

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

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetFirstChild ( const char *  value  )  [inline]

The first child of this node with the matching 'value'. Will be null if none found.

Parameters:
value  The first child of this node with the matching 'value'. Will be null if none found.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetLastChild (  )  [inline]

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

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetLastChild ( const char *  value  )  [inline]

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

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::_IterateChildren ( DigitalSpaces::DIXMLNode1 previous  )  [inline]

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

An alternate way to walk the children of a node. One way to iterate over nodes is:

		for( child = parent->FirstChild( DNoParams ); child; child = child->NextSibling( DNoParams ) )
		

IterateChildren does the same thing with the syntax:

		child DMethodDeclEnd
		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.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::_IterateChildren ( const char *  value,
DigitalSpaces::DIXMLNode1 previous 
) [inline]

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

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::InsertEndChild ( const DigitalSpaces::DIXMLNode1 addThis  )  [inline]

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.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::_LinkEndChild ( DigitalSpaces::DIXMLNode1 addThis  )  [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

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::InsertBeforeChild ( DigitalSpaces::DIXMLNode1 beforeThis,
const DigitalSpaces::DIXMLNode1 addThis 
) [inline]

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.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::InsertAfterChild ( DigitalSpaces::DIXMLNode1 afterThis,
const DigitalSpaces::DIXMLNode1 addThis 
) [inline]

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.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::ReplaceChild ( DigitalSpaces::DIXMLNode1 replaceThis,
const DigitalSpaces::DIXMLNode1 withThis 
) [inline]

Replace a child of this node.

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

Reimplemented from DigitalSpaces::DIXMLNode1.

bool TiXmlNode::RemoveChild ( DigitalSpaces::DIXMLNode1 removeThis  )  [inline]

Delete a child of this node.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetPreviousSibling (  )  [inline]

Navigate to a sibling node.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetPreviousSibling ( const char *  name  )  [inline]

Navigate to a sibling node.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetNextSibling (  )  [inline]

Navigate to a sibling node.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::GetNextSibling ( const char *  name  )  [inline]

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

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLElement1* TiXmlNode::GetNextSiblingElement (  ) 

Convenience function to get through elements.

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

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLElement1* TiXmlNode::GetNextSiblingElement ( const char *  name  ) 

Convenience function to get through elements.

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

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLElement1* TiXmlNode::GetFirstChildElement (  ) 

Convenience function to get through elements.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLElement1* TiXmlNode::GetFirstChildElement ( const char *  value  ) 

Convenience function to get through elements.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::XMLNodeType TiXmlNode::Type (  )  [inline]

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

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

Reimplemented from DigitalSpaces::DIXMLNode1.

bool TiXmlNode::NoChildren (  )  [inline]

Return a pointer to the Document this node lives in.

Returns null if not in a document. Returns true if this node has no children.

Reimplemented from DigitalSpaces::DIXMLNode1.

DigitalSpaces::DIXMLNode1* TiXmlNode::DoClone (  )  [inline]

Reimplemented from DigitalSpaces::DIXMLNode1.

TiXmlNode* TiXmlNode::Identify ( const char *  start  )  [protected]

void TiXmlNode::CopyToClone ( TiXmlNode target  )  const [inline, protected]

const TiXmlString& TiXmlNode::SValue (  )  const [inline, protected]

void TiXmlNode::operator= ( const TiXmlNode base  )  [private]


Friends And Related Function Documentation

friend class TiXmlDocument [friend]

Reimplemented from TiXmlBase.

friend class TiXmlElement [friend]

Reimplemented from TiXmlBase.

Reimplemented in TiXmlText.

TiXmlOutStream& operator<< ( TiXmlOutStream &  out,
const TiXmlNode base 
) [friend]


Field Documentation

Referenced by Parent().

Referenced by FirstChild(), and NoChildren().

Referenced by LastChild().

TiXmlString TiXmlNode::value [protected]

TiXmlNode* TiXmlNode::prev [protected]

Referenced by PreviousSibling().

TiXmlNode* TiXmlNode::next [protected]

Referenced by NextSibling().


The documentation for this class was generated from the following file:

Generated on Sun Aug 31 17:46:28 2008 for Digital Spaces by  doxygen 1.5.6