This function will create a new parser that can be used to iterate over XML documents.
You have to pass a table that contains a selection of callback functions that should
be called while the XML document is being parsed. The following callback functions
can currently be passed in the table argument:
AttlistDecl
-
The function you specify here will be called for attlist declarations in the DTD.
See AttlistDecl for details. (V2.0)
CharacterData
-
The function you specify here will be called for all data that is not part of
any XML entity. See CharacterData for details.
Comment
-
The function you specify here will be called when the parser encounters
a comment in the XML. See Comment for details.
DefaultExpand
-
This is the same as
DefaultHandler
except that the handler doesn't inhibit the
expansion of internal entity references. See DefaultExpand for details.
DefaultHandler
-
The function you specify here will be called when the parser encounters
characters in the document which wouldn't otherwise be handled. See DefaultHandler for details.
ElementDecl
-
The function you specify here will be called for element declarations in
a DTD. See ElementDecl for details. (V2.0)
EndCDataSection
-
The function you specify here will be called when the parser detects the end
of an XML CDATA section. See EndCDataSection for details.
EndDocTypeDecl
-
The function you specify here will be called when the parser reaches the end of
a DOCTYPE declaration. See EndDocTypeDecl for details. (V2.0)
EndElement
-
The function you specify here will be called when an XML node is closed.
See EndElement for details.
EndNamespaceDecl
-
The function you specify here will be called when the parser detects the
end of an XML namespace declaration. Note that you must specify the optional
sep$
parameter
if you want the parser to handle namespaces. See EndNamespaceDecl for details.
EntityDecl
-
The function you specify here will be called when the parser detects an
entity declaration. See EntityDecl for details. (V2.0)
ExternalEntityRef
-
The function you specify here will be called when the parser detects an
external entity reference. See ExternalEntityRef for details.
NotationDecl
-
The function you specify here will be called when the parser encounters
a notation declaration. See NotationDecl for details.
NotStandalone
-
The function you specify here will be called if the document is not standalone
without indicating so in the XML declaration. See NotStandalone for details.
ProcessingInstruction
-
The function you specify here will be called when the parser detects XML processing
instructions. See ProcessingInstruction for details.
SkippedEntity
-
The function you specify here will be called when entities are skipped.
See SkippedEntity for details. (V2.0)
StartCDataSection
-
The function you specify here will be called when the parser detects the beginning
of an XML CDATA section. See StartCDataSection for details.
StartDocTypeDecl
-
The function you specify here will be called when the parser reaches the DOCTYPE
declaration. See StartDocTypeDecl for details.
StartElement
-
The function you specify here will be called when the parser encounters
a new XML node. See StartElement for details.
StartNamespaceDecl
-
The function you specify here will be called when the parser detects an XML
namespace declaration. Note that you must specify the optional
sep$
parameter
if you want the parser to handle namespaces. See StartNamespaceDecl for details.
UnparsedEntityDecl
-
The function you specify here will be called when the parser detects declarations
of unparsed entities. See UnparsedEntityDecl for details. Note that
UnparsedEntityDecl
is obsolete and you should use EntityDecl
instead (see above).
XMLDecl
-
The function you specify here will be called when the parser detects XML declarations.
See XMLDecl for details. (V2.0)
The optional separator character sep$
can be used to define the character used in
the namespace expanded element names. If sep$
isn't defined, the parser will not
handle namespaces.
The optional merge
parameter can be used to configure whether or not the CharacterData
callback should try to merge as much data as possible into a single string. This defaults
to True
. If you set this to False
, your CharacterData
callback could get called more
often because the character data isn't merged into larger chunks.
This function will return a parser object. You can call parser:Parse() to parse
some XML using the parser object. Once you're done with parsing, call parser:Free()
to free the parser object.