Function XmlSimpleParser() Foundation
The function XmlSimpleParser() parses an XML document or XML fragment.
XmlSimpleParser( cXml [, coNode] ) -> oXmlNode
An instance of the XmlNode() or a derived class, which represents the document node of the XML document.
The XmlSimpleParser() function provides a very simple and easy way for processing XML data using objects and their members. This way, the information in the XML document can be easily manipulated using methods and member variables, for example, for iterating over XML nodes or attributes.
Compared to a XML callback processor, using the XmlSimpleParser() is easier and requires fewer lines of code for accessing nodes or attributes. However, using a callback processer is more efficient if large amounts of data (> 1MB) need to be processed.
The following XML document is used as a reference in the paragraphs below. This XML document lists crew members of the Starship Enterprise using different XML notations. Captain James T. Kirk is expressed as child nodes, meaning each value of the first crew entity is written as a child node, while Chief Communications Officer Uhura is expressed using a mixture of attributes. Mr. Chekov is used as an example for node and attribute names containing punctuation marks and similar characters.
The simplicity of the XmlSimpleParser() becomes very clear in the code for retrieving the firstname of the first two crew members. Furthermore, we can see in the example that even so the two XML entities are different in the way their data is structured (node-based versus attribute-based), it makes no difference when accessing the data.
Since it is legal to use hyphens ("-"), punctuation marks (".") and other special characters in node names of an XML document, the data associated with the third crew member cannot be expressed via member variables. However, the XmlNode class provides methods for accessing the information. The method :getAttribute() can be used to access any attribute of a node object by name. The :getChild() method allows retrieving specific child nodes as shown below.
Processing and manipulating a XML document
The following example demonstrates how values can be changed in an existing XML document. Also shown is how new nodes can be created, initialized with data and added to the XML document.
Result of XML document processing and manipulation
The following XML section shows the XML document after it was manipulated by the example above.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.