Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

xmlpp::Document Class Reference

Represents a XML document in the dom model. More...

Inheritance diagram for xmlpp::Document:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Document (const std::string &version="1.0")
virtual ~Document ()
std::string get_encoding () const
Dtdget_internal_subset () const
void set_internal_subset (const std::string &name, const std::string &external_id, const std::string &system_id)
Elementget_root_node () const
 Return the root node.

Elementcreate_root_node (const std::string &name, const std::string &ns_uri=std::string(), const std::string &ns_prefix=std::string())
 Creates the root node.

CommentNodeadd_comment (const std::string &content)
 Append a new comment node.

void write_to_file (const std::string &filename, const std::string &encoding=std::string())
 Write the document to a file.

void write_to_file_formatted (const std::string &filename, const std::string &encoding=std::string())
 Write the document to a file.

std::string write_to_string (const std::string &encoding=std::string())
 Write the document to the memory.

std::string write_to_string_formatted (const std::string &encoding=std::string())
 Write the document to the memory.

void write_to_stream (std::ostream &output, const std::string &encoding=std::string())
 Write the document to a std::ostream.

void write_to_stream_formatted (std::ostream &output, const std::string &encoding=std::string())
 Write the document to a std::ostream.

virtual void set_entity_declaration (const std::string &name, XmlEntityType type, const std::string &publicId, const std::string &systemId, const std::string &content)
 Add an Entity declaration to the document.


Protected Member Functions

_xmlEntity * get_entity (const std::string &name)
 Retrieve an Entity.


Friends

class DomParser
class SaxParser

Detailed Description

Represents a XML document in the dom model.


Constructor & Destructor Documentation

xmlpp::Document::Document const std::string &  version = "1.0"  )  [explicit]
 

virtual xmlpp::Document::~Document  )  [virtual]
 


Member Function Documentation

CommentNode* xmlpp::Document::add_comment const std::string &  content  ) 
 

Append a new comment node.

Parameters:
content The text. This should be unescaped - see ContentNode::set_content().
Returns:
The new comment node.

Element* xmlpp::Document::create_root_node const std::string &  name,
const std::string &  ns_uri = std::string(),
const std::string &  ns_prefix = std::string()
 

Creates the root node.

Parameters:
name The node's name.
ns_uri The namespace URI. A namspace declaration will be added to this node, because it could not have been declared before.
ns_prefix The namespace prefix to associate with the namespace. If no namespace prefix is specified then the namespace URI will be the default namespace.

std::string xmlpp::Document::get_encoding  )  const
 

Returns:
The encoding used in the source from which the document has been loaded.

_xmlEntity* xmlpp::Document::get_entity const std::string &  name  )  [protected]
 

Retrieve an Entity.

The entity can be from an external subset or internally declared.

Parameters:
name Then name of the entity to get.
Returns:
A pointer to the libxml2 entity structure.

Dtd* xmlpp::Document::get_internal_subset  )  const
 

Element* xmlpp::Document::get_root_node  )  const
 

Return the root node.

This function does _not_ create a default root node if it doesn't exist.

Returns:
A pointer to the root node if it exists, 0 otherwise.

virtual void xmlpp::Document::set_entity_declaration const std::string &  name,
XmlEntityType  type,
const std::string &  publicId,
const std::string &  systemId,
const std::string &  content
[virtual]
 

Add an Entity declaration to the document.

Parameters:
name The name of the entity that will be used in an entity reference.
type The type of entity.
publicId The public ID of the subset.
systemId The system ID of the subset.
content The value of the Entity. In entity reference substitutions, this is the replacement value.

void xmlpp::Document::set_internal_subset const std::string &  name,
const std::string &  external_id,
const std::string &  system_id
 

void xmlpp::Document::write_to_file const std::string &  filename,
const std::string &  encoding = std::string()
 

Write the document to a file.

Parameters:
filename 
encoding If not provided, UTF-8 is used

void xmlpp::Document::write_to_file_formatted const std::string &  filename,
const std::string &  encoding = std::string()
 

Write the document to a file.

The output is formatted by inserting whitespaces, which is easier to read for a human, but may insert unwanted significant whitespaces. Use with care !

Parameters:
filename 
encoding If not provided, UTF-8 is used

void xmlpp::Document::write_to_stream std::ostream &  output,
const std::string &  encoding = std::string()
 

Write the document to a std::ostream.

Parameters:
output A reference to the stream in which the document will be written
encoding If not provided, UTF-8 is used
Warning:
This method is much less efficient than write_to_string if you want to dump the document to a buffer or the standard output. Writing to a fstream is almost as fast as write_to_file

void xmlpp::Document::write_to_stream_formatted std::ostream &  output,
const std::string &  encoding = std::string()
 

Write the document to a std::ostream.

The output is formatted by inserting whitespaces, which is easier to read for a human, but may insert unwanted significant whitespaces. Use with care !

Parameters:
output A reference to the stream in which the document will be written
encoding If not provided, UTF-8 is used
Warning:
See write_to_stream

std::string xmlpp::Document::write_to_string const std::string &  encoding = std::string()  ) 
 

Write the document to the memory.

Parameters:
encoding If not provided, UTF-8 is used

std::string xmlpp::Document::write_to_string_formatted const std::string &  encoding = std::string()  ) 
 

Write the document to the memory.

The output is formatted by inserting whitespaces, which is easier to read for a human, but may insert unwanted significant whitespaces. Use with care !

Parameters:
encoding If not provided, UTF-8 is used
Returns:
The written document.


Friends And Related Function Documentation

friend class DomParser [friend]
 

friend class SaxParser [friend]
 


The documentation for this class was generated from the following file:
Generated on Wed May 5 22:52:44 2004 for libxml++ by doxygen 1.3.5