XMLp Bean
Properties Methods Events Configuration Settings Errors
The XMLp component implements a SAX2-compliant XML parser with XPath DOM traversal that can be used to parse and verify the structure of XML documents.
Syntax
IPWorks.Xmlp
Remarks
The XMLp component parses XML documents and verifies that they are well-formed. The results are provided through a set of events complying with the SAX2 specification.
In addition, the document structure may be queried through an XPath mechanism that supports a subset of the XPath specification.
The parser is optimized for read applications, with a very fast engine that builds internal DOM structures with close to zero heap allocations.
The component takes pieces of XML code through the Input method, until Flush is called. The document is parsed and fires events like StartElement, EndElement, Characters, IgnorableWhitespace, PI, etc. Entities are evaluated inside the EvalEntity event. If BuildDOM is set to True, an internal DOM structure is created, which in turn enables properties such as XPath, XElement, XText, etc. which allow traversal of the document structure.
When XPath is set to a valid path, XElement points to the name of the element, with XParent, XNamespace, XPrefix, XChildren, and XText providing other properties of the element. The XAttributes collection provides the attributes of the current element.
An additional "relaxed" mode allows for lexical parsing of non-XML documents (e.g. HTML). This is enabled by setting Validate to False. In this case, events will be fired as elements, entities, etc. are encountered, but the structure of the document will not be checked for "well-formedness", and the internal DOM structure will not be built.
Property List
The following is the full list of the properties of the bean with short descriptions. Click on the links for further details.
BuildDOM | When True, an internal object model of the XML document is created. |
ExtraNameChars | Extra characters for the parser to consider as name characters. |
ExtraSpaceChars | Extra characters for the parser to consider as white space. |
FlushOnEOL | If set, the parser flushes its text buffer after every line of text. |
Namespaces | Collection of namespaces in the current namespace stack. |
Offset | Current offset of the document being parsed. |
Validate | When True, the parser checks that the document consists of well-formed XML. |
XAttributes | A collection of attributes of the current element. |
XChildren | Collection of child elements of the current element. |
XElement | The name of the current element. |
XNamespace | The namespace of the current element. |
XParent | The parent of the current element. |
XPath | Provides a way to point to a specific element in the document. |
XPrefix | The prefix of the current element. |
XSubTree | A snapshot of the current element in the document. |
XText | The text of the current element. |
Method List
The following is the full list of the methods of the bean with short descriptions. Click on the links for further details.
attr | Returns the value of the specified attribute. |
config | Sets or retrieves a configuration setting . |
flush | Flushes the parser and checks its end state. |
hasXPath | Determines whether a specific element exists in the document. |
input | Provides input to the parser. |
loadDOM | Loads the DOM from a file. |
parseFile | Parses the file specified by FileName. |
reset | Resets the parser. |
saveDOM | Saves the DOM to a file. |
Event List
The following is the full list of the events fired by the bean with short descriptions. Click on the links for further details.
Characters | Fired for plain text segments of the input stream. |
Comment | Fired when a comment section is encountered. |
EndElement | Fired when an end-element tag is encountered. |
EndPrefixMapping | Fired when leaving the scope of a namespace declaration. |
Error | Information about errors during data delivery. |
EvalEntity | Fired every time an entity needs to be evaluated. |
IgnorableWhitespace | Fired when a section of ignorable whitespace is encountered. |
Meta | Fired when a meta section is encountered. |
PI | Fired when a processing instruction section is encountered. |
SpecialSection | Fired when a special section is encountered. |
StartElement | Fired when a begin-element tag is encountered in the document. |
StartPrefixMapping | Fired when entering the scope of a namespace declaration. |
Configuration Settings
The following is a list of configuration settings for the bean with short descriptions. Click on the links for further details.
IgnoreBadAttributePrefixes | If true, bad (unknown) attribute prefixes are ignored. |
IgnoreBadElementPrefixes | If true, bad (unknown) element prefixes are ignored. |
CacheContent | If true, the original XML is saved in a buffer. |
ErrorOnEmptyAttr | If true, passing an invalid attribute to the Attr method will throw an exception. |
PreserveWhitespace | If true, leading and trailing whitespace in element text is preserved. |
CodePage | The system code page used for Unicode to Multibyte translations. |