Home > Language Reference > Classes > XmlParser

Parse Method

Starts parsing the document.

Syntax

Public Function Parse(ByRef objData As Stream, Optional ByVal eCharset As HbCharset = hbCharsetUnknown) As Integer

ParameterDescription
objDataXML document to parse.
eCharsetInitial encoding scheme.

Remarks

The Parse method initializes and starts the XML parser. The objData parameter is a data stream containing the document to parse. It can be any data stream as long as it has read permission. You should expect its pointer position to have changed when the function returns. The optional eCharset parameter specifies the encoding scheme of the document, according to the table below:

ConstantValueDescription
hbCharsetUnknown0Determine automatically (default).
hbCharsetUTF81UTF-8
hbCharsetUTF16BE2UTF-16 Big Endian
hbCharsetUTF16LE3UTF-16 Little Endian
hbCharsetLatin14Latin 1, aka ISO 8859-1
hbCharsetLatin95Latin 9, aka ISO 8859-15
hbCharsetWindows12526Windows codepage 1252

Usually, you'll specify hbCharsetUnknown for this parameter, so the parser determines automatically the encoding scheme from the byte order mark and the content of the initial <?xml.. ?> tag. As soon as you receive the first StartElement or CharData event, the Charset property reflects the actual encoding scheme of the document.

The document is immediately parsed, which means your code should be ready to process StartElement, EndElement, CharData and ParseError events before this function returns. The Parse function is not reetrant; calling it while processing these events may lead to unpredictable results.

The return value is negative if an unrecoverable error occured or if the Abort function was called. It is zero if the document was successfully parsed. It is positive if the document was successfully parsed but minor errors were encountered, such as unclosed tags.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A