ICI Modules: xml
Modules by name : by typeOverview
The xml module provides two major facilities. Firsly it is an interface to James Clark's expat XML parser. This is a non-validating XML parser with a SAX-style programming interface. The ICI interface presents a similar interface to the C API and can be considered an ICI SAX implementation.
On top of the direct expat interface a set of functions is provided for reading a complete XML stream into memory. The stream is represented using ICI objects with the XML's structure maintained in the data structure so it is possible to output what has been read. Functions are provided to manipulate this in-memory representation and this can be thought of as a DOM-like interface. It is not however an implementation of the DOM as specified by the W3C but uses this structure.
Interface
The lowest level interface provides direct access to the expat callback-based interface.
xml.ParserCreate - create a new XML parser object
xml.SetUserData - set a parser object's user-defined data
xml.GetUserData - get a parser's user-defined data
xml.SetElementHandler - set a parser's element callbacks
xml.SetCharacterDataHandler - set a parser's character data callback
xml.SetDefaultHandler - set a parser's default callback
xml.SetProcessingInstructionHandler - set a parser's processing instruction callback
xml.Parse - parse input
xml.GetErrorCode - return error code
xml.ErrorString - return error message
xml.GetCurrentLineNumber - return input line number
xml.GetCurrentColumnNumber - return position within current line
xml.GetCurrentByteIndex - return current input byte count
xml.SetBase - set the base URL for the parse
In-memory Interface
This interface uses the above functions to read XML streams into memory and provides functions to traverse the document structure and perform various manipulations.
xml.read - read a document into memory
xml.write - write a document to a stream
xml.process - traverse the document calling functions on matching nodes
xml.traverse - traverse the document calling user functions
xml.tag_of - return an element's tag
xml.id_of - return the internal element unique identifier
xml.elements_of - return an array of sub-elements
xml.attributes_of - return an element's attributes
xml.parent_of - return an element's parent
xml.siblings_of - return an array of the element's siblings
xml.children_of - return an array of child elements
xml.text_of - return the element's character data
xml.empty_element - create an empty element
xml.set_element_tag - set an element's tag
xml.add_element - add an element
xml.find_by_tag - find an element using its tag
xml.is_element - is a sub-element a child
xml.is_text - is a sub-element character data