sxml::XmlNode Class Reference

Class that represents one XML node. More...

#include <xmlNode.h>

List of all members.

Public Member Functions

 XmlNode ()
 Create an incomplete node.
 XmlNode (const NodeType type, const string &name)
 Constructor.
virtual ~XmlNode ()
 Destructor.
void freeSubTree ()
void readFromStream (istream &readFrom, const bool readChildren=true)
 Read the configuration of the node from a stream.
void writeToStream (ostream &writeTo, const bool pretty=true)
 Write the node and all child nodes to a stream.
NodeSearchfindInit (const string &name, const bool ignoreNamespaces=false)
 Create a new search handle.
XmlNodefindNext (NodeSearch *ns)
 Return the next occurrence of the node name to find, NULL if nothing is found.
void findFree (NodeSearch *ns)
 Free a NodeSearch handle.
XmlNodefindFirst (const string &name, const bool ignoreNamespaces=false)
 Find the first occurrence of a node given by name.

Public Attributes

NodeType type
 node type
string name
 name of node (or content if it is a ntTextNode)
bool complete
 whether the subtree is read/written completely
NodeAttributes attributes
 key, value
NodeChildren children


Detailed Description

Class that represents one XML node.

Definition at line 81 of file xmlNode.h.


Constructor & Destructor Documentation

sxml::XmlNode::XmlNode const NodeType  type,
const string &  name
 

Constructor.

Create a completed node.

Parameters:
type NodeType of node
name Node name

Definition at line 54 of file xmlNode.cpp.

References complete.

sxml::XmlNode::~XmlNode  )  [virtual]
 

Destructor.

All child nodes are freed, too (in a recursive manner).

Definition at line 64 of file xmlNode.cpp.

References freeSubTree().


Member Function Documentation

XmlNode * sxml::XmlNode::findFirst const string &  name,
const bool  ignoreNamespaces = false
 

Find the first occurrence of a node given by name.

Parameters:
name The name of the node to find
ignoreNamespaces If true, anything before a ':' in the node's name will be ignored.
Returns:
The pointer to the node found, or NULL if the node is not found.
See also:
XmlNode::findInit(), XmlNode::findNext(), XmlNode::findFree()

Definition at line 801 of file xmlNode.cpp.

References findFree(), findInit(), and findNext().

void sxml::XmlNode::findFree NodeSearch ns  ) 
 

Free a NodeSearch handle.

Parameters:
ns NodeSearch handle to free
See also:
XmlNode::findInit(), XmlNode::findNext(), XmlNode::findFirst()

Definition at line 785 of file xmlNode.cpp.

References sxml::NodeSearch::owner.

Referenced by findFirst().

NodeSearch * sxml::XmlNode::findInit const string &  name,
const bool  ignoreNamespaces = false
 

Create a new search handle.

This handle can be used to iterate nodes with the same name.

Parameters:
name The name of the node to find
ignoreNamespaces If true, anything before a ':' in the node's name will be ignored.
Returns:
A pointer to a NodeSearch handle. This must be freed by XmlNode::findFree().
See also:
XmlNode::findNext(), XmlNode::findFree(), XmlNode::findFirst()

Definition at line 699 of file xmlNode.cpp.

References sxml::NodeSearch::childIndices, sxml::NodeSearch::ignoreNamespaces, sxml::NodeSearch::name, sxml::NodeSearch::owner, and sxml::NodeSearch::parents.

Referenced by findFirst().

XmlNode * sxml::XmlNode::findNext NodeSearch ns  ) 
 

Return the next occurrence of the node name to find, NULL if nothing is found.

Parameters:
ns NodeSearch handle returned by XmlNode::findInit()
Returns:
The next occurrence of the node name to find or NULL if nothing is found.
See also:
XmlNode::findInit(), XmlNode::findFree(), XmlNode::findFirst()

Definition at line 721 of file xmlNode.cpp.

References sxml::NodeSearch::childIndices, sxml::NodeSearch::ignoreNamespaces, sxml::NodeSearch::name, sxml::NodeSearch::owner, and sxml::NodeSearch::parents.

Referenced by findFirst().

void sxml::XmlNode::readFromStream istream &  readFrom,
const bool  readChildren = true
 

Read the configuration of the node from a stream.

The stream should be positioned to a valid start tag of an XML element (e.g. the beginning of a file or any intermediate XML element) - if not, it will return a text element.

Parameters:
readFrom Stream where to read from
readChildren False, if all child elements should also be read (defaults to true)

Definition at line 85 of file xmlNode.cpp.

References attributes, complete, sxml::eBadStream, sxml::eUnexpectedCloseTag, sxml::eUtf8BomError, sxml::eXmlParseError, name, sxml::ntDocTypeNode, sxml::ntDocumentNode, sxml::ntElementNode, type, and XmlNode().

void sxml::XmlNode::writeToStream ostream &  writeTo,
const bool  pretty = true
 

Write the node and all child nodes to a stream.

The format resembles to XML.

Parameters:
writeTo Stream where to write to (e.g. ofstream)
pretty If false, the elements will be written without indention or line breaks (defaults to true)

Definition at line 542 of file xmlNode.cpp.

References complete, sxml::eBadStream, and sxml::eNodeIncomplete.


The documentation for this class was generated from the following files:
Generated on Sun Dec 10 18:47:09 2006 for XmlNode by  doxygen 1.4.6