SUMMARY:  INNER | FIELD | CONSTR | METHOD | FRIEND DETAIL:  FIELD | CONSTR | METHOD | FRIEND


Platform::Text::Xml
Class Document

NonCopyableType
   |
   +-Document

Implemented in:
Platform.Text.Xml.h

class Document:
private NonCopyableType

Represents an XML document.

Inner Compounds, Typedefs, and Enumscollapse
typedef Attributes
          Represents the type of XML document attributes.

Field Summarycollapse
Attributes attributes
          XML document attributes.
StringArray comments
          XML document comments.

Constructor Summarycollapse
Document()
          Creates an empty XML document.
Document(const String& xml, Int fromIndex = 0)
          Creates an XML document by parsing the contents of the specified string.

Method Summarycollapse
UInt deepSize() const
          Computes the total size, in bytes, occupied by this XML document and all of its elements.
Document& parse(const String& xml, Int fromIndex = 0)
          Replaces the current XML document with a new XML document by parsing the contents of the specified string.
Document& reformat(Int flags, Bool recurse = True)
          Re-formats the XML document by applying the specified re-format options.
Element& root()
          Returns the XML document root.
const Element& root() const
          Returns the XML document root.
Element::Collection select(const String& path, Int fromIndex = 0) const
          Searches the XML hierarchy for elements that fulfill a given criteria.
Element::Collection& selectInto(Element::Collection& buffer, const String& path, Int fromIndex = 0) const
          Searches the XML hierarchy for elements that fulfill a given criteria.
String toString(Bool prettyPrint = False) const
          Returns a string representation of the XML document.

 

Field Detail

attributes

Attributes attributes

XML document attributes. The attributes such as encoding, standalone etc.


comments

StringArray comments

XML document comments.

 

Constructor Detail

Document[inline]

Document()

Creates an empty XML document.


Document[inline]

Document(const String& xml, Int fromIndex = 0)

Creates an XML document by parsing the contents of the specified string.

Parameters:
xml - a string containing XML text
fromIndex - starting index within the string
Throws:
Exception - if the specified string does not contain valid XML

 

Method Detail

deepSize[inline]

UInt deepSize() const

Computes the total size, in bytes, occupied by this XML document and all of its elements.

Returns:
the total size, in bytes, occupied by this XML document and all of its elements

parse[inline]

Document& parse(const String& xml, Int fromIndex = 0)

Replaces the current XML document with a new XML document by parsing the contents of the specified string.

Parameters:
xml - a string containing XML text
fromIndex - starting index within the string
Returns:
this document
Throws:
Exception - if the specified string does not contain valid XML

reformat

Document& reformat(Int flags, Bool recurse = True)

Re-formats the XML document by applying the specified re-format options.

Parameters:
flags - re-format options
recurse - specifies whether to re-format the document recursively
Returns:
this document
See Also:
ReformatFlags

root[inline]

Element& root()

Returns the XML document root.

Returns:
the entry element of the XML tree

root[inline]

const Element& root() const

Returns the XML document root.

Returns:
the entry element of the XML tree

select[inline]

Element::Collection select(const String& path, Int fromIndex = 0) const

Searches the XML hierarchy for elements that fulfill a given criteria. The path argument may contain a path to a certain node within XML hierarchy as well as a search criteria rules such as element attributes and position. The nodes of the path are separated by a slash character '/'. Attributes are enclosed in brackets and immediately follow a node name, e.g. node<attribute=value>. To index a certain node use the hash character '#' followed by a number. Positive numbers index the XML nodes from top to bottom in the XML hierarchy where index 0 selects the first matching element. Negative numbers index the XML nodes in the reverse order with -1 selecting the last matching element. Widlcards may be used to partially specify the names of the nodes.

Parameters:
path - the search path and criteria rules
fromIndex - starting index within the path
Returns:
a collection of elements that fulfill the given criteria

selectInto

Element::Collection& selectInto(Element::Collection& buffer, const String& path, Int fromIndex = 0) const

Searches the XML hierarchy for elements that fulfill a given criteria.

Parameters:
buffer - the receiving buffer
path - the search path and criteria rules
fromIndex - starting index within the path
Returns:
a reference to the buffer updated with the elements that fulfill the given criteria

toString

String toString(Bool prettyPrint = False) const

Returns a string representation of the XML document.

Parameters:
prettyPrint - specifies whether to apply internal formatting based on the depth of the elements within the XML hierarchy; expects the document to be re-formatted
Returns:
a string containing textual representation of the XML document


SUMMARY:  INNER | FIELD | CONSTR | METHOD | FRIEND DETAIL:  FIELD | CONSTR | METHOD | FRIEND