class XmlDocument
An easy to use class that represents an XML document tree and provides methods to read and modify the document.
Global Functions
string EscapeChars (const string) | Returns a string where all occurrences of invalid characters have been replaced by their XML entities. |
string UnescapeChars (const string) | Returns a string where all XML entities have been converted back to their respective character. |
Constructors
XmlDocument () | Constructs a new, empty xml-document. |
XmlDocument (const string) | Constructs an xml-document from a string. |
Convertors
string convertor () | Converts the xml-document back to a string. |
Methods
int AddAttribute (const string, const string, const string) | Adds a new attribute to the specified node. |
AddNodeText (const string, const string) | Adds a new text node to the specified node. |
Enumerate (const string, XmlNode::Enumerator, var) | Enumerates the specified node's children and calls the specified delegate for each node. |
string GetAttribute (const string, const string) | Returns the value of the specified attribute of the specified node. |
XmlNode GetNode (const string) | Returns the specified node as a XmlNode object. |
string GetNodeCData (const string) | Returns the specified node's CDATA. |
string GetNodeText (const string) | Returns the specified node's text only. |
int HasAttribute (const string, const string) | Checks if the specified node has the specified attribute. |
int SetAttribute (const string, const string, const string) | Sets the attribute of the specified node to a value. |
SetNodeText (const string, const string) | Sets the first text node of the specified node to a new string. |
Reference
function string EscapeChars (const string s) |
Returns a string where all occurrences of invalid characters have been replaced by their XML entities. |
function string UnescapeChars (const string s) |
Returns a string where all XML entities have been converted back to their respective character. |
method XmlDocument () |
Constructs a new, empty xml-document. |
method XmlDocument (const string str) |
Constructs an xml-document from a string. The string must contain valid xml. XML entities will be automatically converted to their respective character. |
explicit method string convertor () |
Converts the xml-document back to a string. Invalid characters are automatically escaped using XML entities. Depending on the amount of data, this can be slow. |
method int AddAttribute (const string path, const string name, const string value) |
Adds a new attribute to the specified node. If the attribute already exists, false is returned. |
method AddNodeText (const string path, const string text) |
Adds a new text node to the specified node. All nodes in the path are created if they don't already exist. |
method Enumerate (const string path, XmlNode::Enumerator fn, var args) |
Enumerates the specified node's children and calls the specified delegate for each node. This operation is not recursive. |
method string GetAttribute (const string path, const string name) |
Returns the value of the specified attribute of the specified node. If the specified node or attribute does not exist, null is returned. |
method XmlNode GetNode (const string path) |
Returns the specified node as a XmlNode object. If the specified node does not exist, null is returned. |
method string GetNodeCData (const string path) |
Returns the specified node's CDATA. If the node has child nodes, this will actually return them as XML. Invalid characters will be escaped using XML entities. |
method string GetNodeText (const string path) |
Returns the specified node's text only. No escaping is performed. If the node does not have any text, an empty string is returned. |
method int HasAttribute (const string path, const string name) |
Checks if the specified node has the specified attribute. |
method int SetAttribute (const string path, const string name, const string value) |
Sets the attribute of the specified node to a value. If the specified node or attribute does not exist, returns false. |
method SetNodeText (const string path, const string text) |
Sets the first text node of the specified node to a new string. If the node has no text node, it is created. All nodes in the path are created if they don't already exist. |