XMLReader

From Xojo Documentation

Class (inherits from Object)

This is a wrapper class for the latest version of Expat (XML Parser Toolkit). Expat is a library for parsing XML documents.

Events
AttListDecl EndElement StartCDATA
Characters EndPrefixMapping StartDoctypeDecl
Comment EntityDecl StartDocument
Default ExternalEntityRef StartElement
ElementDecl NotStandalone StartPrefixMapping
EndCDATA NotationDecl XMLDecl
EndDoctypeDecl ProcessingInstruction
EndDocument SkippedEntity


Properties
Base CurrentColumnNumber fa-lock-32.png SetDefaultHandler fa-lock-32.png
CurrentByteCount fa-lock-32.png CurrentLineNumber fa-lock-32.png SetDefaultHandlerExpand fa-lock-32.png
CurrentByteIndex fa-lock-32.png ErrorCode fa-lock-32.png


Methods
CreateExternalEntityReader FreeExternalEntityReader Parse
DefaultCurrent Parse Reset


Constructors

XMLReader.Constructor()


XMLReader.Constructor(XMLEncoding as String, namespaceSeparator as String)


Class Constants

The following class constants can be used to test the value in ErrorCode.

Value Constant
0 XML_ERROR_NONE
1 XML_ERROR_NO_MEMORY
2 XML_ERROR_SYNTAX
3 XML_ERROR_NO_ELEMENTS
4 XML_ERROR_INVALID_TOKEN
5 XML_ERROR_UNCLOSED_TOKEN
6 XML_ERROR_PARTIAL_CHAR
7 XML_ERROR_TAG_MISMATCH
8 XML_ERROR_DUPLICATE_ATTRIBUTE
9 XML_ERROR_JUNK_AFTER_DOC_ELEMENT
10 XML_ERROR_PARAM_ENTITY_REF
11 XML_ERROR_UNDEFINED_ENTITY
12 XML_ERROR_RECURSIVE_ENTITY_REF
13 XML_ERROR_ASYNC_ENTITY
14 XML_ERROR_BAD_CHAR_REF
15 XML_ERROR_BINARY_ENTITY_REF
16 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF
17 XML_ERROR_MISPLACED_XML_PI
18 XML_ERROR_UNKNOWN_ENCODING
19 XML_ERROR_INCORRECT_ENCODING
20 XML_ERROR_UNCLOSED_CDATA_SECTION
21 XML_ERROR_EXTERNAL_ENTITY_HANDLING
22 XML_ERROR_NOT_STANDALONE
23 XML_ERROR_UNEXPECTED_STATE
24 XML_ERROR_ENTITY_DECLARED_IN_PE
25 XML_ERROR_FEATURE_REQUIRES_XML_DTD
26 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING

Notes

You will likely use the StartElement event handler to do most of your processing.

XMLReader can be used to parse an XML document instead of using the XMLDocument class. In most cases you will want to use XMLDocument as it is simpler, but XMLReader can be useful for more advanced situtuations:

  • Large XML documents that would take too much memory to load with XMLDocument
  • Where you only need to parse out a subset of the XML and do not need to load the entire document
  • Situations where you want to convert the XML to another format on the fly

To use XMLReader, create a subclass and implement the event handlers.

See Also

XMLReaderException class.