XMLDocument Class Reference

An object representing an XML document. More...

#include <XMLDocument.h++>

Collaboration diagram for XMLDocument:
Collaboration graph
[legend]

List of all members.

Classes

class  XMLParser

Public Member Functions

 XMLDocument (const String &encoding="us-ascii")
 Construct a new XMLDocument with the given character encoding.
 ~XMLDocument () throw ()
 Destructor.
XMLElementgetRoot ()
 Get the root element of the document.
const XMLElementgetRoot () const
 Get the root element of the document.
XMLElementsetRoot (const String &name) throw (InvalidArgumentException)
 Set the root element of the document.
XMLElementfind (const String &path) throw (InvalidArgumentException)
 Find an XML element via a path.
const XMLElementfind (const String &path) const throw (InvalidArgumentException)
 Find an XML element via a path.
void read (std::istream &stream) throw (ParseException, IOException)
 Read and parse the XML document from a stream.
void read (const String &str) throw (ParseException)
 Read and parse the XML document from a String.
void write (std::ostream &stream, uint_t tabWidth=2) const throw (IOException)
 Format and write the XML document to a stream.
void write (String &str, uint_t tabWidth=2) const
 Format and write the XML document to a String.
bool isEmpty () const throw ()
 Test if the document is empty.
bool operator! () const throw ()
 Test if the document is empty.

Detailed Description

An object representing an XML document.

Author:
Mark Lindner

Constructor & Destructor Documentation

XMLDocument ( const String encoding = "us-ascii"  ) 

Construct a new XMLDocument with the given character encoding.

Parameters:
encoding The encoding.
~XMLDocument (  )  throw ()

Destructor.


Member Function Documentation

const XMLElement & find ( const String path  )  const throw (InvalidArgumentException)

Find an XML element via a path.

Parameters:
path The path, a dot- or slash-separated list of element names beginning with the root element.
Returns:
The first matching element, if found, otherwise XMLElement::null.
Exceptions:
InvalidArgumentException If the path contains invalid element names.
XMLElement & find ( const String path  )  throw (InvalidArgumentException)

Find an XML element via a path.

Parameters:
path The path, a dot- or slash-separated list of element names beginning with the root element.
Returns:
The first matching element, if found, otherwise XMLElement::null.
Exceptions:
InvalidArgumentException If the path contains invalid element names.
const XMLElement & getRoot (  )  const

Get the root element of the document.

Returns:
A reference to the root element, or XMLElement::null if the document is empty.
XMLElement & getRoot (  ) 

Get the root element of the document.

Returns:
A reference to the root element, or XMLElement::null if the document is empty.
bool isEmpty (  )  const throw () [inline]

Test if the document is empty.

Returns:
true if the document is empty, false otherwise.
bool operator! (  )  const throw () [inline]

Test if the document is empty.

Returns:
true if the document is empty, false otherwise.
void read ( const String str  )  throw (ParseException)

Read and parse the XML document from a String.

Parameters:
str The String to read from.
Exceptions:
ParseException If a parse error occurs.
void read ( std::istream &  stream  )  throw (ParseException, IOException)

Read and parse the XML document from a stream.

Parameters:
stream The stream to read from.
Exceptions:
ParseException If a parse error occurs.
IOException If an I/O error occurs.
XMLElement & setRoot ( const String name  )  throw (InvalidArgumentException)

Set the root element of the document.

The previous content of the document is deleted.

Parameters:
name The name for the new element.
Returns:
A reference to the new element.
Exceptions:
InvalidArgumentException If the name is invalid.
void write ( String str,
uint_t  tabWidth = 2 
) const

Format and write the XML document to a String.

Parameters:
str The String to write to.
tabWidth The tab width for indentation; a value of 0 disables pretty-printing.
void write ( std::ostream &  stream,
uint_t  tabWidth = 2 
) const throw (IOException)

Format and write the XML document to a stream.

Parameters:
stream The stream to write to.
tabWidth The tab width for indentation; a value of 0 disables pretty-printing.
Exceptions:
IOException If an I/O error occurs.

The documentation for this class was generated from the following files:
Generated on Fri Sep 3 23:49:37 2010 for libcommonc++ by  doxygen 1.6.3