XmlNode Class Reference
[XML]

Base XML node type. More...

#include <XmlNode.h>

Inheritance diagram for XmlNode:
IMemoryValidate XmlAttribute XmlComment XmlDeclaration XmlDocument XmlElement XmlText XmlUnknown

List of all members.

Classes

class  Iterator

Public Types

enum  XmlNodeType {
  DOCUMENT, ELEMENT, COMMENT, UNKNOWN,
  TEXT, DECLARATION, TYPECOUNT, ATTRIBUTE
}
enum  {
  TIXML_NO_ERROR = 0, TIXML_ERROR, TIXML_ERROR_OPENING_FILE, TIXML_ERROR_OUT_OF_MEMORY,
  TIXML_ERROR_PARSING_ELEMENT, TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, TIXML_ERROR_READING_ELEMENT_VALUE, TIXML_ERROR_READING_ATTRIBUTES,
  TIXML_ERROR_PARSING_EMPTY, TIXML_ERROR_READING_END_TAG, TIXML_ERROR_PARSING_UNKNOWN, TIXML_ERROR_PARSING_COMMENT,
  TIXML_ERROR_PARSING_DECLARATION, TIXML_ERROR_DOCUMENT_EMPTY, TIXML_ERROR_EMBEDDED_NULL, TIXML_ERROR_PARSING_CDATA,
  TIXML_ERROR_DOCUMENT_TOP_ONLY, TIXML_ERROR_STRING_COUNT
}

Public Member Functions

const StringPtr Value () const
virtual String Name () const =0
void SetValue (const String &_value)
void Clear ()
 Delete all the children of this node. Does not affect 'this'.
XmlNodePtr ParentNode () const
 One step up the DOM.
virtual RefCountPtr< XmlNodeListChildNodes () const
XmlNodePtr FirstChild () const
 The first child of this node. Will be null if there are no children.
XmlNodePtr FirstChild (const String &value) const
 The first child of this node with the matching 'value'. Will be null if none found.
XmlNodePtr LastChild () const
 The last child of this node. Will be null if there are no children.
XmlNodePtr LastChild (const String &value) const
 The last child of this node matching 'value'. Will be null if there are no children.
XmlNodePtr Child (int index) const
void AppendChild (XmlNodePtr addThis)
void InsertBefore (XmlNodePtr beforeThis, XmlNodePtr addThis)
void InsertAfter (XmlNodePtr afterThis, XmlNodePtr addThis)
void ReplaceChild (XmlNodePtr replaceThis, XmlNodePtr withThis)
bool RemoveChild (XmlNodePtr removeThis)
 Delete a child of this node.
virtual RefCountPtr< XmlNodeListDecendants ()
XmlNodePtr PreviousSibling ()
 Navigate to a sibling node.
XmlNodePtr PreviousSibling (const String &)
 Navigate to a sibling node.
XmlNodePtr NextSibling ()
 Navigate to a sibling node.
XmlNodePtr NextSibling (const String &)
 Navigate to a sibling node with the given 'value'.
XmlElementPtr NextSiblingElement ()
XmlElementPtr NextSiblingElement (const String &)
XmlElementPtr FirstChildElement ()
 Convenience function to get through elements.
XmlElementPtr FirstChildElement (const String &_value)
 Convenience function to get through elements.
XmlNodeType NodeType () const
XmlDocumentPtr GetDocument ()
bool HasChildNodes () const
 Returns true if this node has no children.
virtual XmlNodePtr Clone () const =0
 Performs a deep copy.
virtual StringPtr InnerText () const
RefCountPtr< XmlNodeListSelectNodes (const String &xpath)
 Select all of the nodes matching the expression.
XmlNodePtr SelectSingleNode (const String &xpath)
 Select the first node matching the expression. This may not be the first matching node in tree order.
int Row () const
int Column () const
 See Row().
virtual XmlDocumentPtr ToDocument () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual XmlElementPtr ToElement () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual XmlCommentPtr ToComment () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual XmlUnknownPtr ToUnknown () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual XmlTextPtr ToText () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual XmlDeclarationPtr ToDeclaration () const
 Cast to a more defined type. Will return null if not of the requested type.
bool IsDocument () const
bool IsElement () const
bool IsComment () const
bool IsUnknown () const
bool IsText () const
bool IsDeclaration () const
bool IsAttribute () const
StringPtr OuterXml () const
virtual StringPtr InnerXml () const
virtual StringPtr ToString () const =0
virtual void WriteTo (TextWriter &writer) const =0
Iterator Begin ()
virtual void ValidateMem () const
virtual void CheckMem () const

Protected Member Functions

 XmlNode (XmlNodeType _type)
void CopyTo (XmlNode &target) const
XmlNodePtr Identify (const char *start, XmlEncoding encoding)
virtual const char * _Parse (const char *p, XmlParsingData *data, XmlEncoding encoding)=0

Protected Attributes

XmlNodem_parent
XmlNodeType m_type
XmlNodePtr m_firstChild
XmlNodePtr m_lastChild
StringBuffer m_value
XmlNodePtr m_prev
XmlNodePtr m_next
TiXmlCursor m_location
XmlNodeRef m_self

Friends

class XmlDocument
class TinyXmlParser
class XmlElement

Detailed Description

Base XML node type.

Definition at line 94 of file XmlNode.h.


Member Enumeration Documentation

The types of XML nodes supported by TinyXml. (All the unsupported types are picked up by UNKNOWN.)

Definition at line 105 of file XmlNode.h.


Member Function Documentation

void XmlNode::AppendChild ( XmlNodePtr  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 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.

Definition at line 93 of file TinyXmlNode.cpp.

References GetDocument(), and LastChild().

Referenced by XmlDocument::_Parse().

XmlDocumentPtr XmlNode::GetDocument (  ) 

Return a pointer to the Document this node lives in. Returns null if not in a document.

Definition at line 380 of file TinyXmlNode.cpp.

Referenced by AppendChild().

void XmlNode::InsertAfter ( XmlNodePtr  afterThis,
XmlNodePtr  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.

Definition at line 150 of file TinyXmlNode.cpp.

void XmlNode::InsertBefore ( XmlNodePtr  beforeThis,
XmlNodePtr  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.

Definition at line 123 of file TinyXmlNode.cpp.

XmlElementPtr XmlNode::NextSiblingElement ( const String _value  ) 

Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

Definition at line 366 of file TinyXmlNode.cpp.

References NextSibling().

XmlElementPtr XmlNode::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.

Definition at line 352 of file TinyXmlNode.cpp.

References NextSibling().

XmlNodeType XmlNode::NodeType (  )  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 331 of file XmlNode.h.

void XmlNode::ReplaceChild ( XmlNodePtr  replaceThis,
XmlNodePtr  withThis 
)

Replace a child of this node. Returns a pointer to the new object or NULL if an error occured.

Definition at line 177 of file TinyXmlNode.cpp.

int XmlNode::Row (  )  const [inline]

Return the position, in the original source file, of this node or attribute. The row and column are 1-based. (That is the first row and first column is 1,1). If the returns values are 0 or less, then the parser does not have a row and column value.

Generally, the row and column value will be set when the TiXmlDocument::Load(), TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set when the DOM was created from operator>>.

The values reflect the initial load. Once the DOM is modified programmatically (by adding or changing nodes and attributes) the new values will NOT update to reflect changes in the document.

There is a minor performance cost to computing the row and column. Computation can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.

See also:
TiXmlDocument::SetTabSize()

Definition at line 376 of file XmlNode.h.

void XmlNode::SetValue ( const String _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 in XmlAttribute.

Definition at line 221 of file XmlNode.h.

Referenced by XmlComment::XmlComment(), and XmlText::XmlText().

const StringPtr XmlNode::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 205 of file XmlNode.h.


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