clan::DomDocument Class Reference

DOM Document class. More...

#include <dom_document.h>

+ Inheritance diagram for clan::DomDocument:

Public Member Functions

 DomDocument ()
 Constructs a DOM Document. More...
 
 DomDocument (IODevice &input, bool eat_whitespace=true)
 Constructs a DomDocument. More...
 
 DomDocument (const DomString &namespace_uri, const DomString &qualified_name, const DomDocumentType &doctype)
 
 DomDocument (const std::shared_ptr< DomNode_Impl > &impl)
 Constructs a DomDocument. More...
 
 ~DomDocument ()
 
void clear_all ()
 Removes all nodes from the DOM document. More...
 
DomAttr create_attribute (const DomString &name)
 Creates an Attr of the given name. More...
 
DomAttr create_attribute_ns (const DomString &namespace_uri, const DomString &qualified_name)
 Creates an attribute of the given qualified name and namespace URI. More...
 
DomCDATASection create_cdata_section (const DomString &data)
 Creates a CDATASection node whose value is the specified string. More...
 
DomComment create_comment (const DomString &data)
 Creates a Comment node given the specified string. More...
 
DomDocumentFragment create_document_fragment ()
 Creates an empty DocumentFragment object. More...
 
DomElement create_element (const DomString &tag_name)
 Creates an element of the type specified. More...
 
DomElement create_element_ns (const DomString &namespace_uri, const DomString &qualified_name)
 Creates an element of the given qualified name and namespace URI. More...
 
DomEntityReference create_entity_reference (const DomString &name)
 Creates an EntityReference object. More...
 
DomProcessingInstruction create_processing_instruction (const DomString &target, const DomString &data)
 Creates a ProcessingInstruction node given the specified name and data strings. More...
 
DomText create_text_node (const DomString &data)
 Creates a Text node given the specified string. More...
 
DomDocumentType get_doctype ()
 Returns the Document Type Declaration (see DomDocumentType)associated with this document. More...
 
DomElement get_document_element ()
 Returns the root document element node. More...
 
DomElement get_element_by_id (const DomString &element_id)
 Returns the Element whose ID is given by element_id. More...
 
DomNodeList get_elements_by_tag_name (const DomString &tag_name)
 Returns a NodeList of all the Elements with a given tag name. More...
 
DomNodeList get_elements_by_tag_name_ns (const DomString &namespace_uri, const DomString &qualified_name)
 Returns a NodeList of all the Elements with a given local name and namespace URI. More...
 
DomImplementation get_implementation ()
 Returns the DomImplementation object that handles this document. More...
 
DomNode import_node (const DomNode &node, bool deep)
 Imports a node from another document to this document. More...
 
std::vector< DomNodeload (IODevice &input, bool eat_whitespace=true, DomNode insert_point=DomNode())
 Loads the DOM document as XML from an input source. More...
 
void save (IODevice &output, bool insert_whitespace=true)
 Saves the DOM document as XML to an input source. More...
 
- Public Member Functions inherited from clan::DomNode
 DomNode ()
 
 DomNode (const DomNode &copy)
 Constructs a DomNode. More...
 
 ~DomNode ()
 
DomNode append_child (DomNode new_child)
 Adds the node new_child to the end of the list of children of this node. More...
 
DomNode clone_node (bool deep) const
 Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. More...
 
DomString find_namespace_uri (const DomString &qualified_name) const
 Searches the node tree upwards for the namespace URI of the given qualified name. More...
 
DomString find_prefix (const DomString &namespace_uri) const
 Searches the node tree upwards for the prefix name for the namespace URI. More...
 
DomNamedNodeMap get_attributes () const
 A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise. More...
 
DomNodeList get_child_nodes () const
 Returns a NodeList that contains all children of this node. More...
 
DomNode get_first_child () const
 The first child of this node. More...
 
DomNode get_last_child () const
 The last child of this node. More...
 
DomString get_local_name () const
 Returns local part of the qualified name of this node. More...
 
DomString get_namespace_uri () const
 Returns the namespace URI of this node. More...
 
DomNode get_next_sibling () const
 The node immediately following this node. More...
 
DomString get_node_name () const
 Returns the node name. More...
 
unsigned short get_node_type () const
 Returns the node type (one of those in the NodeType enum). More...
 
DomString get_node_value () const
 Returns the node value. More...
 
DomDocument get_owner_document () const
 The Document object associated with this node. More...
 
DomNode get_parent_node () const
 Returns the parent of this node. More...
 
DomString get_prefix () const
 Returns the namespace prefix of the node. More...
 
DomNode get_previous_sibling () const
 The node immediately preceding this node. More...
 
bool has_attributes () const
 Returns true if this node (if its an element) has any attributes. More...
 
bool has_child_nodes () const
 Returns true if this node has any children. More...
 
DomNode insert_before (DomNode &new_child, DomNode &ref_child)
 Inserts the node new_child before the existing child node ref_child. More...
 
bool is_attr () const
 Returns true if this is an attribute node. More...
 
bool is_cdata_section () const
 Returns true if this is a CDATA section node. More...
 
bool is_comment () const
 Returns true if this is a comment node. More...
 
bool is_document () const
 Returns true if this is a document node. More...
 
bool is_document_fragment () const
 Returns true if this is a document fragment node. More...
 
bool is_document_type () const
 Returns true if this is a document type node. More...
 
bool is_element () const
 Returns true if this is an element node. More...
 
bool is_entity () const
 Returns true if this is an entity node. More...
 
bool is_entity_reference () const
 Returns true if this is an entity reference node. More...
 
bool is_notation () const
 Returns true if this is a notation node. More...
 
bool is_null () const
 Returns true if this is a null node. More...
 
bool is_processing_instruction () const
 Returns true if this is a processing instruction node. More...
 
bool is_supported (const DomString &feature, const DomString &version) const
 Tests whether the DOM implementation implements a specific feature and that feature is supported by this node. More...
 
bool is_text () const
 Returns true if this is a text node. More...
 
DomNode named_item (const DomString &name) const
 Returns the first child node with the specified node name. More...
 
DomNode named_item_ns (const DomString &namespace_uri, const DomString &local_name) const
 Retrieves the first child node with the specified namespace URI and local name. More...
 
void normalize ()
 Merges any adjacent Text nodes. More...
 
bool operator!= (const DomNode &other) const
 Compare operator. More...
 
DomNodeoperator= (const DomNode &copy)
 Copy assignment operator. More...
 
bool operator== (const DomNode &other) const
 Compare operator. More...
 
DomNode remove_child (DomNode &old_child)
 Removes the child node indicated by old_child from the list of children, and returns it. More...
 
DomNode replace_child (DomNode &new_child, DomNode &old_child)
 Replaces the child node old_child with new_child in the list of children. More...
 
bool select_bool (const DomString &xpath_expression) const
 Returns the first node value (as boolean) matching the specified xpath expression using this node as the context node. More...
 
float select_float (const DomString &xpath_expression) const
 Returns the first node value (as float) matching the specified xpath expression using this node as the context node. More...
 
int select_int (const DomString &xpath_expression) const
 Returns the first node value (as integer) matching the specified xpath expression using this node as the context node. More...
 
DomNode select_node (const DomString &xpath_expression) const
 Returns the first node matching the specified xpath expression using this node as the context node. More...
 
std::vector< DomNodeselect_nodes (const DomString &xpath_expression) const
 Returns all the nodes matching the specified xpath expression using this node as the context node. More...
 
std::string select_string (const DomString &xpath_expression) const
 Returns the first node value matching the specified xpath expression using this node as the context node. More...
 
void set_node_value (const DomString &value)
 Sets the node value. More...
 
void set_prefix (const DomString &prefix)
 Sets the namespace prefix of the node. More...
 
DomAttr to_attr () const
 Returns the Attribute interface to this node. More...
 
DomCDATASection to_cdata_section () const
 Returns the CDATA Section interface to this node. More...
 
DomComment to_comment () const
 Returns the Comment interface to this node. More...
 
DomDocument to_document () const
 Returns the Document interface to this node. More...
 
DomDocumentFragment to_document_fragment () const
 Returns the Document Fragment interface to this node. More...
 
DomDocumentType to_document_type () const
 Returns the Document Type interface to this node. More...
 
DomElement to_element () const
 Returns the Element interface to this node. More...
 
DomEntity to_entity () const
 Returns the Entity interface to this node. More...
 
DomEntityReference to_entity_reference () const
 Returns the Entity Reference interface to this node. More...
 
DomNotation to_notation () const
 Returns the Notation interface to this node. More...
 
DomProcessingInstruction to_processing_instruction () const
 Returns the Processing Instruction interface to this node. More...
 
DomText to_text () const
 Returns the Text interface to this node. More...
 

Additional Inherited Members

- Public Types inherited from clan::DomNode
enum  NodeType {
  NULL_NODE = 0, ELEMENT_NODE = 1, ATTRIBUTE_NODE = 2, TEXT_NODE = 3,
  CDATA_SECTION_NODE = 4, ENTITY_REFERENCE_NODE = 5, ENTITY_NODE = 6, PROCESSING_INSTRUCTION_NODE = 7,
  COMMENT_NODE = 8, DOCUMENT_NODE = 9, DOCUMENT_TYPE_NODE = 10, DOCUMENT_FRAGMENT_NODE = 11,
  NOTATION_NODE = 12
}
 An integer indicating which type of node this is. More...
 
- Protected Member Functions inherited from clan::DomNode
 DomNode (DomDocument doc, unsigned short node_type)
 
 DomNode (const std::shared_ptr< DomNode_Impl > &impl)
 
- Protected Attributes inherited from clan::DomNode
std::shared_ptr< DomNode_Impl > impl
 

Detailed Description

DOM Document class.

The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.

Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.

Constructor & Destructor Documentation

clan::DomDocument::DomDocument ( )

Constructs a DOM Document.

clan::DomDocument::DomDocument ( IODevice input,
bool  eat_whitespace = true 
)

Constructs a DomDocument.

Parameters
input= IODevice
eat_whitespace= bool
clan::DomDocument::DomDocument ( const DomString namespace_uri,
const DomString qualified_name,
const DomDocumentType doctype 
)
clan::DomDocument::DomDocument ( const std::shared_ptr< DomNode_Impl > &  impl)

Constructs a DomDocument.

Parameters
impl= Shared Ptr
clan::DomDocument::~DomDocument ( )

Member Function Documentation

void clan::DomDocument::clear_all ( )

Removes all nodes from the DOM document.

DomAttr clan::DomDocument::create_attribute ( const DomString name)

Creates an Attr of the given name.

Note that the Attr instance can then be set on an Element using the setAttribute method.

Parameters
nameThe name of the attribute.
DomAttr clan::DomDocument::create_attribute_ns ( const DomString namespace_uri,
const DomString qualified_name 
)

Creates an attribute of the given qualified name and namespace URI.

Note that the Attr instance can then be set on an Element using the setAttribute method.

DomCDATASection clan::DomDocument::create_cdata_section ( const DomString data)

Creates a CDATASection node whose value is the specified string.

Parameters
dataThe data for the CDATASection contents.
DomComment clan::DomDocument::create_comment ( const DomString data)

Creates a Comment node given the specified string.

Parameters
dataThe data for the node.
DomDocumentFragment clan::DomDocument::create_document_fragment ( )

Creates an empty DocumentFragment object.

DomElement clan::DomDocument::create_element ( const DomString tag_name)

Creates an element of the type specified.

Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.

Parameters
tag_nameThe name of the element type to instantiate. For XML, this is case-sensitive.
DomElement clan::DomDocument::create_element_ns ( const DomString namespace_uri,
const DomString qualified_name 
)

Creates an element of the given qualified name and namespace URI.

DomEntityReference clan::DomDocument::create_entity_reference ( const DomString name)

Creates an EntityReference object.

Parameters
nameThe name of the entity to reference.
DomProcessingInstruction clan::DomDocument::create_processing_instruction ( const DomString target,
const DomString data 
)

Creates a ProcessingInstruction node given the specified name and data strings.

Parameters
targetThe target part of the processing instruction.
dataThe data for the node.
DomText clan::DomDocument::create_text_node ( const DomString data)

Creates a Text node given the specified string.

Parameters
dataThe data for the node.
DomDocumentType clan::DomDocument::get_doctype ( )

Returns the Document Type Declaration (see DomDocumentType)associated with this document.

For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 1 does not support editing the Document Type Declaration, therefore docType cannot be altered in any way.

DomElement clan::DomDocument::get_document_element ( )

Returns the root document element node.

This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tag name "HTML".

DomElement clan::DomDocument::get_element_by_id ( const DomString element_id)

Returns the Element whose ID is given by element_id.

DomNodeList clan::DomDocument::get_elements_by_tag_name ( const DomString tag_name)

Returns a NodeList of all the Elements with a given tag name.

The list is in the order in which they would be encountered in a preorder traversal of the Document tree.

Parameters
tag_nameThe name of the tag to match on. The special value "*" matches all tags.
DomNodeList clan::DomDocument::get_elements_by_tag_name_ns ( const DomString namespace_uri,
const DomString qualified_name 
)

Returns a NodeList of all the Elements with a given local name and namespace URI.

The list is in the order in which they would be encountered in a preorder traversal of the Document tree.

DomImplementation clan::DomDocument::get_implementation ( )

Returns the DomImplementation object that handles this document.

DomNode clan::DomDocument::import_node ( const DomNode node,
bool  deep 
)

Imports a node from another document to this document.

The returned node has no parent. The source node is not altered or removed from the original document; this method creates a new copy of the source node.

For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's node_name and node_type, plus the attributes related to namespaces (prefix, local_name, and namespace_uri). As in the clone_node operation on a Node, the source node is not altered.

std::vector<DomNode> clan::DomDocument::load ( IODevice input,
bool  eat_whitespace = true,
DomNode  insert_point = DomNode() 
)

Loads the DOM document as XML from an input source.

Parameters
inputInput source to read from.
eat_whitespacePassed on to XMLTokenizer::set_eat_whitespace.
insert_pointPlace in the DOM to insert the loaded XML code.
Returns
List of all top level nodes created.
void clan::DomDocument::save ( IODevice output,
bool  insert_whitespace = true 
)

Saves the DOM document as XML to an input source.

Parameters
outputOutput source to write to.
insert_whitespacePassed on to XMLWriter::set_insert_whitespace.

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