#include <XMLDocument.h>
Inheritance diagram for util::xml::Node:

The names and the fields of this class and its subclasses conform roughly to the DOM 1.0 specification.
Note that when a Node is deleted, all of its children are deleted as well.
Public Types | |
| enum | NodeType { DOCUMENT_NODE, ELEMENT_NODE, ATTRIBUTE_NODE, PROCESSING_INSTRUCTION_NODE, DECLARATION_NODE, TEXT_NODE, COMMENT_NODE, CDATA_SECTION_NODE } |
| An enumeration of different node types. More... | |
Public Methods | |
| virtual | ~Node () |
| Destroy a node and all of its children. | |
| NodeType | getNodeType () const |
| Get the actual type of this node. | |
| void | appendChild (Node *child) |
| Add a child node to this node. | |
| void | removeChild (Node *child) |
| Remove a child node from this node. | |
| List< Node * > | getChildNodes () const |
| Get the children of this node in insertion order. | |
| List< Node * > | getChildNodes (NodeType type, std::string name="") const |
| Get the child nodes whose type matches to the given type (and name). | |
| const List< Node * > & | childNodes () const |
| Get the children of this node in insertion order. | |
| List< Node * > & | childNodes () |
| Get the children of this node in insertion order. | |
| bool | hasChildNodes () const |
| Check whether this node has children. | |
| const Node * | getParentNode () const |
| Get the parent node. | |
| Node * | getParentNode () |
| Get the parent node. | |
| void | setParentNode (Node *parent) |
| Set the parent node. | |
| Node & | operator= (const Node &other) |
| Copy a node. | |
| const Node * | getChildNode (std::string name) const |
| Get a pointer to a node rooted at this node. | |
| virtual std::string | getName () const |
| Get the name of this node. | |
| std::string | getTypeName () const |
| Get the type name of this node. | |
| bool | isInternalName (std::string name) const |
| Check if a name is an internal name, i.e. | |
| virtual void | printOut (std::ostream &out) const=0 throw (util::io::IOException&) |
| Print the contents of a node to a stream. | |
Protected Methods | |
| Node (NodeType type) | |
| Node cannot be directly instantiated. | |
| Node (const Node &other) | |
| Copy a node. | |
Protected Attributes | |
| Node * | _pParent |
| A pointer to the parent node. | |
| List< Node * > | _plstChildren |
| A list of child nodes. | |
|
|
An enumeration of different node types. Each node type has a corresponding class:
|
|
|
Node cannot be directly instantiated. Instead, subclasses must provide it a type when instantiating. |
|
|
Copy a node. Only the type of the node is copied. |
|
|
Get a pointer to a node rooted at this node. This method has no DOM correspondent. Let us suppose you have a Document node with a root node labeled 'root'. You can get a reference to the root node by using "document.element[root]" or just "document.root" as a node name. The attributes of 'root' would be accessible through "document.root.attribute[name]". (See explanation below.) An internal name is associated with each node type:
<?xml version="1.0"> <root type="foo"> This is the first text section. <text>Here we have some more text.</text> <text attr="foo">And here, too.</text> </root> For this document, the previous examples would give the following results:
<?xml version="1.0"> <root foo="X"> <foo/> </root> Now, using 'document.root.foo' as a node path returns the attribute 'foo', but 'document.root.element[foo]' returns the empty child element.
|
|
||||||||||||
|
Get the child nodes whose type matches to the given type (and name). For example, getChildNodes(Node::ATTRIBUTE_NODE) returns all attributes that are direct childs of this node. In a similar manner, getChildNodes(Node::ELEMENT_NODE,"child") returns all direct child elements whose name is "child". This method has no DOM correspondent.
|
|
|
Get the name of this node. Attributes, elements, processing instructions and declarations return the name found in the markup. Other node types return an internal name like 'document', 'text' etc.
Reimplemented in util::xml::Attr, util::xml::ProcessingInstruction, util::xml::Declaration, and util::xml::Element. |
|
|
Get the actual type of this node. If this returns, say, DOCUMENT_NODE, a Node* can be safely casted to Document*. |
|
|
Get the type name of this node.
|
|
|
Check if a name is an internal name, i.e. 'document', 'text' etc.
|
|
|
Copy a node. Only the type of the node is copied. |
|
|
Print the contents of a node to a stream. The output of this method is well-formed XML. Calling the printOut method of a Document object produces a well-formed XML document. All other nodes produce a well-formed XML document fraction.
Implemented in util::xml::Text, util::xml::Comment, util::xml::CDATASection, util::xml::Attr, util::xml::ProcessingInstruction, util::xml::Declaration, util::xml::Element, and util::xml::Document. |