The XmlReader class
The om.XmlReader
class provides methods to read and process a file
written in XML format.
The processing of the XML file is streamed-data based; the file is loaded and processed
sequentially with events. To process XML element attributes, an om.XmlReader
object must cooperate with a om.SaxAttributes
object. The
XmlReader class can only read from a file. To write to a file, use the om.XmlWriter
class.
Steps to use a XML reader:
- Declare a variable with the
om.XmlReader
type. - Create the reader object with the
createFileReader()
method and assign the reference to the variable. - Process SAX events in a
WHILE
loop, by reading document fragments with theread()
method. - Inside the loop, depending on the SAX event, process element attributes with getAttributes() or get the element data with the getCharacters() methods.