3.14. XML Functions

XML functions allow serializing and deserializing between XML strings and qore data structures. There are also functions for XML-RPC support; see below for details and see the XmlRpcClient Class for a class supporting communication with this protocol.

3.14.1. makeFormattedXMLFragment()

Synopsis

Serializes a hash into an XML string with formatting without an XML header.

Usage
makeFormattedXMLFragment(hash, [encoding])
Example
$xml = makeFormattedXMLFragment($hash);

Table 3.383. Arguments and Return Values for makeFormattedXMLFragment()

Argument Type

Return Type

Description

Hash, [String]

String

Serializes the Qore hash to an XML string (see XML Integration for more information) without an XML header but with formatting. The hash must have only one top-level key or an exception will be thrown.


Table 3.384. Exceptions Thrown by makeFormattedXMLFragment()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.2. makeFormattedXMLRPCCallString()

Synopsis

Serializes the arguments into an XML string in XML-RPC call format with whitespace formatting.

Usage
makeFormattedXMLRPCCallString(method_name, [arguments ...])
Example
$xml = makeFormattedXMLRPCCallString("method.name", $arg1, $arg2);

Table 3.385. Arguments and Return Values for makeFormattedXMLRPCCallString()

Argument Type

Return Type

Description

String, [Any ...]

String

Serializes the arguments into an XML string in XML-RPC call format with whitespace formatting. The encoding of the resulting string will always be the default encoding.


Table 3.386. Exceptions Thrown by makeFormattedXMLRPCCallString()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.3. makeFormattedXMLRPCCallStringWithEncoding()

Synopsis

Serializes the arguments into an XML string for an XML-RPC call with whitespace formatting, taking an initial string argument to give the encoding for the created XML.

Usage
makeFormattedXMLRPCCallStringWithEncoding(encoding_name, method_name, [arguments ...])
Example
$xml = makeFormattedXMLRPCCallStringWithEncoding("ISO-8859-1", "method.name", $arg1, $arg2);

Table 3.387. Arguments and Return Values for makeFormattedXMLRPCCallStringWithEncoding()

Argument Type

Return Type

Description

String, String, [Any ...]

String

Serializes the arguments into an XML string in XML-RPC call format with whitespace formatting. The encoding of the resulting string will be the encoding given by the first argument.


Table 3.388. Exceptions Thrown by makeFormattedXMLRPCCallStringWithEncoding()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.4. makeFormattedXMLRPCCallStringArgs()

Synopsis

Serializes the arguments into an XML string in XML-RPC call format with whitespace formatting, taking a single argument following the XML-RPC method name for the argument list to the method.

Usage
makeFormattedXMLRPCCallStringArgs(method_name, [arg_list])
Example
$xml = makeFormattedXMLRPCCallStringArgs("method.name", $arg_list);

Table 3.389. Arguments and Return Values for makeFormattedXMLCallStringArgs()

Argument Type

Return Type

Description

String, [List]

String

Serializes the arguments into an XML string in XML-RPC call format with whitespace formatting, using a single argument following the XML-RPC method name as the argument list for the method. The encoding of the resulting string will always be the default encoding.


Table 3.390. Exceptions Thrown by makeFormattedXMLRPCCallStringArgs()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.5. makeFormattedXMLRPCCallStringArgsWithEncoding()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC call with whitespace formatting, taking an initial string argument to give the encoding for the created XML, followed by the method name, followed by a single list argument for the argument list.

Usage
makeFormattedXMLRPCCallStringArgsWithEncoding(encoding_name, method_name, [arg_list])
Example
$xml = makeFormattedXMLRPCCallStringArgsWithEncoding("ISO-8859-1", "method.name", $arg_list);

Table 3.391. Arguments and Return Values for makeFormattedXMLCallStringArgsWithEncoding()

Argument Type

Return Type

Description

String, String, [List]

String

Serializes the arguments into an XML string in XML-RPC call format with whitespace formatting, using a single argument following the XML-RPC method name as the argument list for the method. The encoding of the resulting string will be the encoding given by the first argument.


Table 3.392. Exceptions Thrown by makeFormattedXMLRPCCallStringArgsWithEncoding()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.6. makeFormattedXMLRPCFaultResponseString()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC fault response with whitespace formatting.

Usage
makeFormattedXMLRPCFaultResponseString(error_code, error_string)
Example
$xml = makeFormattedXMLRPCFaultResponseString(10, "oh no, big error");

Table 3.393. Arguments and Return Values for makeFormattedXMLRPCFaultResponseString()

Argument Type

Return Type

Description

Integer, String

String

Serializes the arguments into an XML string formatted for an XML-RPC fault response with whitespace formatting. The encoding of the resulting string will always be the default encoding.


Table 3.394. Exceptions Thrown by makeFormattedXMLRPCCallStringArgs()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.

MAKE-XMLRPC-FAULT-RESPONSE-STRING-PARAMETER-ERROR

missing either the error code or the error string arguments.


3.14.7. makeFormattedXMLRPCFaultResponseStringWithEncoding()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC fault response with whitespace formatting, taking an initial string argument to give the encoding for the created XML.

Usage
makeFormattedXMLRPCFaultResponseStringWithEncoding(encoding_name, error_code, error_string)
Example
$xml = makeFormattedXMLRPCFaultResponseStringWithEncoding("ISO-8859-2", 10, "oh no, big error");

Table 3.395. Arguments and Return Values for makeFormattedXMLRPCFaultResponseStringWithEncoding()

Argument Type

Return Type

Description

String, Integer, String

String

Serializes the arguments into an XML string formatted for an XML-RPC fault response with whitespace formatting. The encoding of the resulting string will be the encoding given by the first argument.


Table 3.396. Exceptions Thrown by makeFormattedXMLRPCCallStringArgsWithEncoding()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.

MAKE-XMLRPC-FAULT-RESPONSE-STRING-PARAMETER-ERROR

missing either the error code or the error string arguments.


3.14.8. makeFormattedXMLRPCResponseString()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC response with whitespace formatting.

Usage
makeFormattedXMLRPCResponseString(any)
Example
$xml = makeFormattedXMLRPCResponseString($value);

Table 3.397. Arguments and Return Values for makeFormattedXMLRPCResponseString()

Argument Type

Return Type

Description

Any

String

Serializes the arguments into an XML string formatted for an XML-RPC response with whitespace formatting>. The encoding of the resulting string will always be the default encoding.


Table 3.398. Exceptions Thrown by makeFormattedXMLRPCResponseString()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.9. makeFormattedXMLRPCResponseStringWithEncoding()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC response with whitespace formatting, taking an initial string argument to give the encoding for the created XML.

Usage
makeFormattedXMLRPCResponseStringWithEncoding(encoding_name, any)
Example
$xml = makeFormattedXMLRPCResponseStringWithEncoding("ISO-8859-1", $value);

Table 3.399. Arguments and Return Values for makeFormattedXMLRPCResponseStringWithEncoding()

Argument Type

Return Type

Description

Any

String

Serializes the arguments into an XML string formatted for an XML-RPC response with whitespace formatting>. The encoding of the resulting string is given by the first argument.


Table 3.400. Exceptions Thrown by makeFormattedXMLRPCResponseStringWithEncoding()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.10. makeFormattedXMLRPCValueString()

Synopsis

Serializes the arguments into an XML string in XML-RPC value format with whitespace formatting.

Usage
makeFormattedXMLRPCValueString(any)
Example
$xml = makeFormattedXMLRPCValueString($value);

Table 3.401. Arguments and Return Values for makeFormattedXMLRPCValueString()

Argument Type

Return Type

Description

Any

String

Serializes the arguments into an XML string in XML-RPC value format with whitespace formatting. The encoding of the resulting string will always be the default encoding.


Table 3.402. Exceptions Thrown by makeFormattedXMLRPCValueString()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.11. makeFormattedXMLString()

Synopsis

Serializes a hash into an XML string with formatting and an XML header.

Usage
makeFormattedXMLString(hash, [encoding])
makeFormattedXMLString(string, hash, [encoding])
Examples
$xml = makeFormattedXMLString($hash);
$xml = makeFormattedXMLString("key", $hash);

Table 3.403. Arguments and Return Values for makeFormattedXMLString()

Argument Type

Return Type

Description

Hash, [String]

String

Serializes the Qore hash to an XML string (see XML Integration for more information) with an XML header and formatting. The hash must have only one top-level key or an exception will be thrown.

String, Hash, [String]

String

Serializes the Qore hash to an XML string (see XML Integration for more information) with an XML header and formatting. The first parameter will be the top-level XML element.


Table 3.404. Exceptions Thrown by makeFormattedXMLRPCValueString()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.

MAKE-FORMATTED-XML-STRING-PARAMETER-EXCEPTION

Incorrect arguments passed.


3.14.12. makeXMLFragment()

Synopsis

Serializes a hash into an XML string without whitespace formatting and without an XML header.

Usage
makeXMLFragment(hash, [encoding])
Example
$xml = makeXMLFragment($hash);

Table 3.405. Arguments and Return Values for makeXMLFragment()

Argument Type

Return Type

Description

Hash, [String]

String

Serializes the Qore hash to an XML string (see XML Integration for more information) without an XML header and without whitespace formatting. The hash must have only one top-level key or an exception will be thrown.


Table 3.406. Exceptions Thrown by makeXMLFragment()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.13. makeXMLRPCCallString()

Synopsis

Serializes the arguments into an XML string in XML-RPC call format without whitespace formatting.

Usage
makeXMLRPCCallString(method_name, [arguments ...])
Example
$xml = makeXMLRPCCallString("method.name", $arg1, $arg2);

Table 3.407. Arguments and Return Values for makeXMLRPCCallString()

Argument Type

Return Type

Description

String, [Any ...]

String

Serializes the arguments into an XML string in XML-RPC call format without whitespace formatting. The encoding of the resulting string will always be the default encoding.


Table 3.408. Exceptions Thrown by makeXMLRPCCallString()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.14. makeXMLRPCCallStringWithEncoding()

Synopsis

Serializes the arguments into an XML string in XML-RPC call format without whitespace formatting, taking an initial string argument to give the target character encoding for the XML string.

Usage
makeXMLRPCCallStringWithEncoding(encoding_name, method_name, [arguments ...])
Example
$xml = makeXMLRPCCallStringWithEncoding("ISO-8859-2", "method.name", $arg1, $arg2);

Table 3.409. Arguments and Return Values for makeXMLRPCCallStringWithEncoding()

Argument Type

Return Type

Description

String, String, [Any ...]

String

Serializes the arguments into an XML string in XML-RPC call format without whitespace formatting. The encoding of the resulting string will correspond to the encoding given as the first argument.


Table 3.410. Exceptions Thrown by makeXMLRPCCallStringWithEncoding()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.15. makeXMLRPCCallStringArgs()

Synopsis

Serializes the arguments into an XML string in XML-RPC call format without whitespace formatting, taking a single argument following the XML-RPC method name for the argument list to the method.

Usage
makeXMLRPCCallStringArgs(method_name, [arg_list])
Example
$xml = makeXMLRPCCallStringArgs("method.name", $arg_list);

Table 3.411. Arguments and Return Values for makeXMLCallStringArgs()

Argument Type

Return Type

Description

String, [List]

String

Serializes the arguments into an XML string in XML-RPC call format without whitespace formatting, using a single argument following the XML-RPC method name as the argument list for the method. The encoding of the resulting string will always be the default encoding.


Table 3.412. Exceptions Thrown by makeXMLRPCCallStringArgs()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.16. makeXMLRPCCallStringArgsWithEncoding()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC call without whitespace formatting, taking an initial string argument to give the target character encoding for the XML string followed by a list argument for the argument list.

Usage
makeXMLRPCCallStringArgsWithEncoding(encoding_name, method_name, [arg_list])
Example
$xml = makeXMLRPCCallStringArgsWithEncoding("ISO-8859-2", "method.name", $arg_list);

Table 3.413. Arguments and Return Values for makeXMLCallStringArgsWithEncoding()

Argument Type

Return Type

Description

String, String, [List]

String

Serializes the arguments into an XML string in XML-RPC call format without whitespace formatting, using a single argument following the XML-RPC method name as the argument list for the method. The encoding of the resulting string will correspond to the encoding given as the first argument to the function.


Table 3.414. Exceptions Thrown by makeXMLRPCCallStringArgsWithEncoding()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.17. makeXMLRPCFaultResponseString()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC fault response without whitespace formatting.

Usage
makeXMLRPCFaultResponseString(error_code, error_string)
Example
$xml = makeXMLRPCFaultResponseString(10, "oh no, an error occured");

Table 3.415. Arguments and Return Values for makeXMLRPCFaultResponseString()

Argument Type

Return Type

Description

Integer, String

String

Serializes the arguments into an XML string formatted for an XML-RPC fault response without whitespace formatting. The encoding of the resulting string will always be the encoding of the fault string (2nd argument).


Table 3.416. Exceptions Thrown by makeXMLRPCCallStringArgs()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.

MAKE-XMLRPC-FAULT-RESPONSE-STRING-PARAMETER-ERROR

missing either the error code or the error string arguments.


3.14.18. makeXMLRPCFaultResponseStringWithEncoding()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC fault response without whitespace formatting, taking an initial string argument to give the target character encoding for the XML string.

Usage
makeXMLRPCFaultResponseStringWithEncoding(encoding_string, error_code, error_string)
Example
$xml = makeXMLRPCFaultResponseStringWithEncoding("ISO-8859-2", 10, "oh no, an error occured");

Table 3.417. Arguments and Return Values for makeXMLRPCFaultResponseStringWithEncoding()

Argument Type

Return Type

Description

String, Integer, String

String

Serializes the arguments into an XML string formatted for an XML-RPC fault response without whitespace formatting. The encoding of the resulting string will correspond to the encoding given as the first argument.


Table 3.418. Exceptions Thrown by makeXMLRPCCallStringArgsWithEncoding()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.

MAKE-XMLRPC-FAULT-RESPONSE-STRING-PARAMETER-ERROR

missing either the error code or the error string arguments.


3.14.19. makeXMLRPCResponseString()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC response without whitespace formatting.

Usage
makeXMLRPCResponseString(any)
Example
$xml = makeXMLRPCResponseString($response);

Table 3.419. Arguments and Return Values for makeXMLRPCResponseString()

Argument Type

Return Type

Description

Any

String

Serializes the arguments into an XML string formatted for an XML-RPC response without whitespace formatting>. The encoding of the resulting string will always be the default encoding.


Table 3.420. Exceptions Thrown by makeXMLRPCResponseString()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.20. makeXMLRPCResponseStringWithEncoding()

Synopsis

Serializes the arguments into an XML string formatted for an XML-RPC response without whitespace formatting.

Usage
makeXMLRPCResponseStringWithEncoding(encoding_name, any)
Example
$xml = makeXMLRPCResponseStringWithEncoding("ISO-8859-2", $response);

Table 3.421. Arguments and Return Values for makeXMLRPCResponseStringWithEncoding()

Argument Type

Return Type

Description

String, Any

String

Serializes the arguments into an XML string formatted for an XML-RPC response without whitespace formatting>. The encoding of the resulting string will correspond to the first argument.


Table 3.422. Exceptions Thrown by makeXMLRPCResponseStringWithEncoding()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.21. makeXMLRPCValueString()

Synopsis

Serializes the arguments into an XML string in XML-RPC value format without whitespace formatting.

Usage
makeXMLRPCValueString(any)
Example
$xml = makeXMLRPCValueString($value);

Table 3.423. Arguments and Return Values for makeXMLRPCValueString()

Argument Type

Return Type

Description

Any

String

Serializes the arguments into an XML string in XML-RPC value format without whitespace formatting. The encoding of the resulting string will always be the default encoding.


Table 3.424. Exceptions Thrown by makeXMLRPCValueString()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.


3.14.22. makeXMLString()

Synopsis

Serializes a hash into an XML string without whitespace formatting but with an XML header.

Usage
makeXMLString(hash, [encoding])
makeXMLString(string, hash, [encoding])
Examples
$xml = makeXMLString($hash);
$xml = makeXMLString("key", $hash);

Table 3.425. Arguments and Return Values for makeXMLString()

Argument Type

Return Type

Description

Hash, [String]

String

Serializes the Qore hash to an XML string (see XML Integration for more information) with an XML header but without whitespace formatting. The hash must have only one top-level key or an exception will be thrown.

String, Hash, [String]

String

Serializes the Qore hash to an XML string (see XML Integration for more information) with an XML header but without whitespace formatting. The first parameter will be the top-level XML element.


Table 3.426. Exceptions Thrown by makeXMLRPCValueString()

err

desc

MAKE-XML-ERROR

An error occurred serializing the Qore data to an XML string.

MAKE-XML-STRING-PARAMETER-EXCEPTION

Incorrect arguments passed.


3.14.23. parseXMLAsData()

Synopsis

Parses an XML string as data (does not preserve hash order with out-of-order duplicate keys: collapses all to the same list) and returns a Qore hash structure.

Note that data deserialized with this function may not be reserialized to an identical XML string to the input due to the fact that duplicate, out-of-order XML elements are collapsed into lists in the resulting Qore hash, thereby losing the order in the original XML string.

For a similar function preserving the order of keys in the XML in the resulting Qore hash by generating Qore hash element names with numeric suffixes, see parseXML().

Usage
parseXMLAsData(xml_string, [output_encoding])
Example
$hash = parseXMLAsData($xml);

Table 3.427. Arguments and Return Values for parseXMLAsData()

Argument Type

Return Type

Description

String, [String]

Hash

Parses an XML string and returns a Qore hash structure.


Table 3.428. Exceptions Thrown by parseXMLAsData()

err

desc

PARSE-XML-EXCEPTION

Error parsing the XML string.


3.14.24. parseXMLAsDataWithRelaxNG()

Synopsis

Parses an XML string as data (does not preserve hash order with out-of-order duplicate keys: collapses all to the same list), validates the XML string against a RelaxNG schema string, and returns a Qore hash structure. If any errors occur parsing the RelaxNG schema string, parsing the XML string, or validating the XML against the XSD, exceptions are thrown. If no encoding string argument is passed, then all strings in the resulting hash will be in UTF-8 encoding regardless of the input encoding of the XML string.

Please note that data deserialized with this function may not be reserialized to an identical XML string to the input due to the fact that duplicate, out-of-order XML elements are collapsed into lists in the resulting Qore hash, thereby losing the order in the original XML string.

For a similar function preserving the order of keys in the XML in the resulting Qore hash by generating Qore hash element names with numeric suffixes, see parseXMLWithRelaxNG(). See also parseXMLAsDataWithSchema() and parseXMLWithSchema().

The availability of this function depends on the presence of libxml2's xmlTextReaderRelaxNGSetSchema() function when Qore was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHRELAXNG before running this function. See Library Option Constants for a list of all option constants.

Usage
parseXMLAsDataWithRelaxNG(xml_string, relaxng_string, [output_encoding])
Example
$hash = parseXMLAsDataWithRelaxNG($xml, $rng);

Table 3.429. Arguments and Return Values for parseXMLAsDataWithRelaxNG()

Argument Type

Return Type

Description

String, String, [String]

Hash

Parses an XML string (1st argument), validates against the RelaxNG string (2nd argument), and returns a Qore hash structure.


Table 3.430. Exceptions Thrown by parseXMLAsDataWithRelaxNG()

err

desc

PARSE-XML-EXCEPTION

Error parsing the XML string.

PARSE-XML-AS-DATA-WITH-RELAXNG-ERROR

Invalid arguments passed to the function.

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHRELAXNG before calling this function.


3.14.25. parseXMLAsDataWithSchema()

Synopsis

Parses an XML string as data (does not preserve hash order with out-of-order duplicate keys: collapses all to the same list), validates the XML string against an XSD schema string, and returns a Qore hash structure. If any errors occur parsing the XSD string, parsing the XML string, or validating the XML against the XSD, exceptions are thrown. If no encoding string argument is passed, then all strings in the resulting hash will be in UTF-8 encoding regardless of the input encoding of the XML string.

Please note that data deserialized with this function may not be reserialized to an identical XML string to the input due to the fact that duplicate, out-of-order XML elements are collapsed into lists in the resulting Qore hash, thereby losing the order in the original XML string.

For a similar function preserving the order of keys in the XML in the resulting Qore hash by generating Qore hash element names with numeric suffixes, see parseXMLWithSchema(). See also parseXMLAsDataWithRelaxNG() and parseXMLWithRelaxNG().

The availability of this function depends on the presence of libxml2's xmlTextReaderSetSchema() function when Qore was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHSCHEMA before running this function. See Library Option Constants for a list of all option constants.

Usage
parseXMLAsDataWithSchema(xml_string, xsd_string, [output_encoding])
Example
$hash = parseXMLAsDataWithSchema($xml, $xsd);

Table 3.431. Arguments and Return Values for parseXMLAsDataWithSchema()

Argument Type

Return Type

Description

String, String, [String]

Hash

Parses an XML string (1st argument), validates against the XSD string (2nd argument), and returns a Qore hash structure.


Table 3.432. Exceptions Thrown by parseXMLAsDataWithSchema()

err

desc

PARSE-XML-EXCEPTION

Error parsing the XML string.

PARSE-XML-WITH-SCHEMA-ERROR

Invalid arguments passed to the function.

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHSCHEMA before calling this function.


3.14.26. parseXML()

Synopsis

Parses an XML string and returns a Qore hash structure. If duplicate, out-of-order XML elements are found in the input string, they are deserialized to Qore hash elements with the same name as the XML element but including a caret "^" and a numeric prefix to maintain the same key order in the Qore hash as in the input XML string.

For a similar function collapsing all duplicate XML elements into a list in the Qore hash, see parseXMLAsData().

Usage
parseXML(xml_string, [output_encoding])
Example
$hash = parseXML($xml);

Table 3.433. Arguments and Return Values for parseXML()

Argument Type

Return Type

Description

String, [String]

Hash

Parses an XML string and returns a Qore hash structure.


Table 3.434. Exceptions Thrown by parseXML()

err

desc

PARSE-XML-EXCEPTION

Error parsing the XML string.


3.14.27. parseXMLWithRelaxNG()

Synopsis

Parses an XML string, validates the XML string against a RelaxNG schema string, and returns a Qore hash structure. If any errors occur parsing the RelaxNG string, parsing the XML string, or validating the XML against the RelaxNG schema, exceptions are thrown. If no encoding string argument is passed, then all strings in the resulting hash will be in UTF-8 encoding regardless of the input encoding of the XML string.

If duplicate, out-of-order XML elements are found in the input string, they are deserialized to Qore hash elements with the same name as the XML element but including a caret "^" and a numeric prefix to maintain the same key order in the Qore hash as in the input XML string.

For a similar function collapsing all duplicate XML elements into a list in the Qore hash, see parseXMLAsDataWithRelaxNG(). See also parseXMLWithSchema() and parseXMLAsDataWithSchema()

.

The availability of this function depends on the presence of libxml2's xmlTextReaderRelaxNGSetSchema() function when Qore was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHRELAXNG before running this function. See Library Option Constants for a list of all option constants.

Usage
parseXMLWithRelaxNG(xml_string, relaxng_string, [output_encoding])
Example
$hash = parseXMLWithRelaxNG($xml, $rng);

Table 3.435. Arguments and Return Values for parseXMLWithRelaxNG()

Argument Type

Return Type

Description

String, String, [String]

Hash

Parses an XML string (1st argument), validates against the RelaxNG schema string (2nd argument), and returns a Qore hash structure.


Table 3.436. Exceptions Thrown by parseXMLWithRelaxNG()

err

desc

PARSE-XML-EXCEPTION

Error parsing the XML string.

PARSE-XML-WITH-RELAXNG-ERROR

Invalid arguments passed to the function.

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHRELAXNG before calling this function.


3.14.28. parseXMLWithSchema()

Synopsis

Parses an XML string, validates the XML string against an XSD schema string, and returns a Qore hash structure. If any errors occur parsing the XSD string, parsing the XML string, or validating the XML against the XSD, exceptions are thrown. If no encoding string argument is passed, then all strings in the resulting hash will be in UTF-8 encoding regardless of the input encoding of the XML string.

If duplicate, out-of-order XML elements are found in the input string, they are deserialized to Qore hash elements with the same name as the XML element but including a caret "^" and a numeric prefix to maintain the same key order in the Qore hash as in the input XML string.

For a similar function collapsing all duplicate XML elements into a list in the Qore hash, see parseXMLAsDataWithSchema(). See also parseXMLWithRelaxNG() and parseXMLAsDataWithRelaxNG()

.

The availability of this function depends on the presence of libxml2's xmlTextReaderSetSchema() function when Qore was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHSCHEMA before running this function. See Library Option Constants for a list of all option constants.

Usage
parseXMLWithSchema(xml_string, xsd_string, [output_encoding])
Example
$hash = parseXMLWithSchema($xml, $xsd);

Table 3.437. Arguments and Return Values for parseXMLWithSchema()

Argument Type

Return Type

Description

String, String, [String]

Hash

Parses an XML string (1st argument), validates against the XSD string (2nd argument), and returns a Qore hash structure.


Table 3.438. Exceptions Thrown by parseXMLWithSchema()

err

desc

PARSE-XML-EXCEPTION

Error parsing the XML string.

PARSE-XML-WITH-SCHEMA-ERROR

Invalid arguments passed to the function.

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHSCHEMA before calling this function.


3.14.29. parseXMLRPCCall()

Synopsis

Deserializies an XML-RPC call string, returning a Qore data structure representing the call information.

Usage
parseXMLRPCCall(xmlrpc_call_string, [output_encoding])
Example
$hash = parseXMLRPCCall($xml);

Table 3.439. Arguments and Return Values for parseXMLRPCCall()

Argument Type

Return Type

Description

String, [String]

Hash

Deserializies an XML-RPC call string, returning a Qore data structure representing the call information. The hash will have the following keys: methodName, params


Table 3.440. Exceptions Thrown by parseXMLRPCCall()

err

desc

PARSE-XMLRPC-CALL-ERROR

Error parsing the XML-RPC call string.

PARSE-XMLRPC-VALUE-ERROR

Error parsing an XML-RPC value node.


3.14.30. parseXMLRPCResponse()

Synopsis

Deserializies an XML-RPC response string, returning a Qore data structure representing the response information.

Usage
parseXMLRPCResponse(xmlrpc_response_string, [output_encoding])
Example
$hash = parseXMLRPCResponse($xml);

Table 3.441. Arguments and Return Values for parseXMLRPCResponse()

Argument Type

Return Type

Description

String, [String]

Hash

Deserializies an XML-RPC response string, returning a Qore data structure representing the response information. The hash will have either a "fault" or a "params" key, depending on if it's a fault response or a non-fault response.


Table 3.442. Exceptions Thrown by parseXMLRPCResponse()

err

desc

PARSE-XMLRPC-RESPONSE-ERROR

Error parsing the XML-RPC response string.

PARSE-XMLRPC-VALUE-ERROR

Error parsing an XML-RPC value node.


3.14.31. parseXMLRPCValue()

Synopsis

Deserializies an XML-RPC value tree, returning a Qore data structure representing the information.

Usage
parseXMLRPCValue(xmlrpc_value_string, [output_encoding])
Example
$hash = parseXMLRPCValue($xml);

Table 3.443. Arguments and Return Values for parseXMLRPCValue()

Argument Type

Return Type

Description

String, [String]

Hash

Deserializies an XML-RPC value string, returning Qore data representing the value data.


Table 3.444. Exceptions Thrown by parseXMLRPCResponse()

err

desc

PARSE-XMLRPC-VALUE-ERROR

Error parsing an XML-RPC value node.