Function EN Version 10.01

@XMLParse

XML

Syntax

@XMLParse(XML);
@XMLParse(XML;Flags);

Description

This @Function reads an XML document from a text value or binary buffer and creates an internal XML document structure from it.
The returned XML document reference can be processed using the other @XML… functions. After processing has been completed, it should be released using @XMLRelease.
Internally, the XML document structure is stored in UTF-8. Therefore, @XMLParse provides options (see Flags) for automatically converting input and output parameters.

TEXT/VSPECBINBUFFER XML:
The XML document to be read.
The XML document must contain syntactically valid XML.

FN Flags (Optional):
Numeric value containing additional options for reading the XML document.

BIT   DEC   HEX   BEDEUTUNG wenn gesetzt
01   000001   00001   XML_FLAG_OUTPUT_TRANSLATE_LMBCS   (Converts query results to LMBCS)
02   000002   00002   XML_FLAG_QUERY_TRANSLATE_UTF8   (Converts query parameters to UTF-8)
03   000004   00004   XML_FLAG_INPUT_TRANSLATE_UTF8   (Converts the input data to UTF-8 before parsing)
The flags can be combined and are inherited by derived handles.

Return Value:
If the input cannot be interpreted as valid XML, @XMLParse returns @ERROR. Otherwise, it returns a VSPECHXMLDOC (XMLD) handle.

The error message contains the position of the error within the XML data, together with an error code and a description of the parser error.
If available from the XML parser, the error message also contains the line and column number, for example:
XML parsing failed at line 12, column 7: …
If no detailed parser error is available, an error is returned indicating that the XML document is not well-formed.

Notes:
External network resources are not loaded during parsing. Processing of external XML entities is also disabled.
The XML document reference created by @XMLParse remains valid until it is released using @XMLRelease.

Example: @XMLParse(INPUT);

XML := "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<customer>" +
" <name>Example GmbH</name>" +
" <city>Berlin</city>" +
"</customer>";

hXMLD := @XMLParse(XML);
Root := @XMLGetRoot(hXMLD);
@XMLRelease(hXMLD);

The example reads an XML document, retrieves its root element "<customer>", and then releases the XML structure.

Example: @XMLParse(INPUT;FLAGS);

XML := "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<customer>" +
" <name>Müller GmbH</name>" +
" <city>Berlin</city>" +
"</customer>";

Flags:=7;
hXMLD := @XMLParse(XML;Flags);
hXMLRoot := @XMLGetRoot(hXMLD);
@XMLRelease(hXMLD);

The example reads an XML document, retrieves its root element "<customer>", and then releases the XML structure.
All input parameters and query results are automatically converted from LMBCS to UTF-8 or from UTF-8 to LMBCS as appropriate.
Before parsing, the ‚ü‘ in "Müller" is therefore converted from LMBCS to UTF-8.

Note : This text was machine-translated and may contain inaccuracies.