Qore XML Module  1.5
XML Functions

Functions

string Qore::Xml::makeFormattedXMLFragment (hash h, *string encoding)
 serializes a hash into an XML string with whitespace formatting but without an XML header More...
 
nothing Qore::Xml::makeFormattedXMLFragment ()
 This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters. More...
 
string Qore::Xml::makeFormattedXMLString (string key, hash h, *string encoding)
 serializes a hash into an XML string with whitespace formatting and with an XML header More...
 
string Qore::Xml::makeFormattedXMLString (hash h, *string encoding)
 serializes a hash into an XML string with whitespace formatting and with an XML header More...
 
string Qore::Xml::makeXMLFragment (hash h, *string encoding)
 serializes a hash into an XML string without whitespace formatting and without an XML header More...
 
nothing Qore::Xml::makeXMLFragment ()
 This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters. More...
 
string Qore::Xml::makeXMLString (string key, hash h, *string encoding)
 serializes a hash into an XML string without whitespace formatting but with an XML header More...
 
string Qore::Xml::makeXMLString (hash h, *string encoding)
 serializes a hash into an XML string without whitespace formatting but with an XML header More...
 
string Qore::Xml::make_xml (string key, hash h, *int flags, *string encoding)
 serializes a hash into an XML string with an XML header More...
 
string Qore::Xml::make_xml (hash h, *int flags, *string encoding)
 serializes a hash into an XML string with an XML header More...
 
string Qore::Xml::make_xml (hash h, hash opts)
 serializes a hash into an XML string with various options of formatting More...
 
string Qore::Xml::make_xml_fragment (hash h, *int flags, *string encoding)
 serializes a hash into an XML string without whitespace formatting and without an XML header More...
 
hash Qore::Xml::parseXML (string xml, *string encoding)
 Parses an XML string and returns a Qore hash structure. More...
 
nothing Qore::Xml::parseXML ()
 This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters. More...
 
hash Qore::Xml::parseXMLAsData (string xml, *string encoding)
 Parses an XML string as data (does not necessarily preserve key order) and returns a Qore hash structure. More...
 
nothing Qore::Xml::parseXMLAsData ()
 This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters. More...
 
hash Qore::Xml::parseXMLAsDataWithRelaxNG (string xml, string relaxng, *string encoding)
 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. More...
 
hash Qore::Xml::parseXMLAsDataWithSchema (string xml, string xsd, *string encoding)
 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. More...
 
hash Qore::Xml::parseXMLWithRelaxNG (string xml, string relaxng, *string encoding)
 Parses an XML string, validates the XML string against a RelaxNG schema string, and returns a Qore hash structure. More...
 
hash Qore::Xml::parseXMLWithSchema (string xml, string xsd, *string encoding)
 Parses an XML string, validates the XML string against an XSD schema string, and returns a Qore hash structure. More...
 
hash Qore::Xml::parse_xml (string xml, *int pflags, *string encoding)
 Parses an XML string and returns a Qore hash structure. More...
 
hash Qore::Xml::parse_xml_with_dtd (string xml, string dtd, *int pflags, *string encoding)
 Parses an XML string, validates the XML string against a DTD string, and returns a Qore hash structure. More...
 
hash Qore::Xml::parse_xml_with_relaxng (string xml, string relaxng, *int pflags, *string encoding)
 Parses an XML string, validates the XML string against a RelaxNG schema string, and returns a Qore hash structure. More...
 
hash Qore::Xml::parse_xml_with_schema (string xml, string xsd, *int pflags, *string encoding)
 Parses an XML string, validates the XML string against an XSD schema string, and returns a Qore hash structure. More...
 

Detailed Description

Function Documentation

◆ make_xml() [1/3]

string Qore::Xml::make_xml ( string  key,
hash  h,
*int  flags,
*string  encoding 
)

serializes a hash into an XML string with an XML header

Code Flags:
RET_VALUE_ONLY
Example:
string xml = make_xml("key", hash);
Parameters
keytop-level key
hthe rest of the data to serialize under the top-level key
flagsoptional formatting flags; see XML Generation Constants for more information
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, with an XML header
Exceptions
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Since
xml 1.3 as a replacement for deprecated camel-case makeXMLString() and makeFormattedXMLString()

◆ make_xml() [2/3]

string Qore::Xml::make_xml ( hash  h,
*int  flags,
*string  encoding 
)

serializes a hash into an XML string with an XML header

Code Flags:
RET_VALUE_ONLY
Example:
string xml = make_xml(hash);
Parameters
ha hash of data to serialize: the hash must have one top-level key and no more or an exception will be raised
flagsoptional formatting flags; see XML Generation Constants for more information
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, with an XML header
Exceptions
MAKE-XML-STRING-PARAMETER-EXCEPTIONthe hash passed not not have a single top-level key (either has no keys or more than one)
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Since
xml 1.3 as a replacement for deprecated camel-case makeXMLString() and makeFormattedXMLString()

◆ make_xml() [3/3]

string Qore::Xml::make_xml ( hash  h,
hash  opts 
)

serializes a hash into an XML string with various options of formatting

Code Flags:
RET_VALUE_ONLY
Example:
string xml = make_xml(hash, opts);
Parameters
ha hash of data to serialize: the hash must have one top-level key and no more or an exception will be raised
optsformatting and other serialization settings; see XML Generation Options for more information
Returns
an XML string corresponding to the input data
Exceptions
MAKE-XML-STRING-PARAMETER-EXCEPTIONthe hash passed does not have a single top-level key (either has no keys or more than one)
MAKE-XML-OPTS-INVALIDthe opts hash passed is not valid; see XML Generation Options for more information
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Since
xml 1.4

◆ make_xml_fragment()

string Qore::Xml::make_xml_fragment ( hash  h,
*int  flags,
*string  encoding 
)

serializes a hash into an XML string without whitespace formatting and without an XML header

Code Flags:
RET_VALUE_ONLY
Example:
string xml = make_xml_fragment(hash);
Parameters
ha hash of data to serialize: the hash can have any number of keys
flagsoptional formatting flags; see XML Generation Constants for more information
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, without whitespace formatting and without an XML header
Exceptions
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Since
xml 1.3 as a replacement for deprecated camel-case makeXMLFragment()

◆ makeFormattedXMLFragment() [1/2]

string Qore::Xml::makeFormattedXMLFragment ( hash  h,
*string  encoding 
)

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

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
ha hash of data to serialize: the hash can have any number of keys
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, with whitespace formatting but without an XML header
Exceptions
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Deprecated:
use make_xml_fragment(); camel-case function names were deprecated in xml 1.3

◆ makeFormattedXMLFragment() [2/2]

nothing Qore::Xml::makeFormattedXMLFragment ( )

This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters.

Code Flags:
RUNTIME_NOOP, DEPRECATED

◆ makeFormattedXMLString() [1/2]

string Qore::Xml::makeFormattedXMLString ( string  key,
hash  h,
*string  encoding 
)

serializes a hash into an XML string with whitespace formatting and with an XML header

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
keytop-level key
hthe rest of the data to serialize under the top-level key
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, with whitespace formatting and with an XML header
Exceptions
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Deprecated:
use make_xml(); camel-case function names were deprecated in xml 1.3

◆ makeFormattedXMLString() [2/2]

string Qore::Xml::makeFormattedXMLString ( hash  h,
*string  encoding 
)

serializes a hash into an XML string with whitespace formatting and with an XML header

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
ha hash of data to serialize: the hash must have one top-level key and no more or an exception will be raised
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, with whitespace formatting and with an XML header
Exceptions
MAKE-FORMATTED-XML-STRING-PARAMETER-EXCEPTIONthe hash passed not not have a single top-level key (either has no keys or more than one)
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Deprecated:
use make_xml(); camel-case function names were deprecated in xml 1.3

◆ makeXMLFragment() [1/2]

string Qore::Xml::makeXMLFragment ( hash  h,
*string  encoding 
)

serializes a hash into an XML string without whitespace formatting and without an XML header

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
ha hash of data to serialize: the hash can have any number of keys
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, without whitespace formatting and without an XML header
Exceptions
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Deprecated:
use make_xml_fragment(); camel-case function names were deprecated in xml 1.3

◆ makeXMLFragment() [2/2]

nothing Qore::Xml::makeXMLFragment ( )

This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters.

Code Flags:
RUNTIME_NOOP, DEPRECATED

◆ makeXMLString() [1/2]

string Qore::Xml::makeXMLString ( string  key,
hash  h,
*string  encoding 
)

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

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
keytop-level key
hthe rest of the data to serialize under the top-level key
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, without whitespace formatting but with an XML header
Exceptions
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Deprecated:
use make_xml(); camel-case function names were deprecated in xml 1.3

◆ makeXMLString() [2/2]

string Qore::Xml::makeXMLString ( hash  h,
*string  encoding 
)

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

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
ha hash of data to serialize: the hash must have one top-level key and no more or an exception will be raised
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, the output string will have the default encoding
Returns
an XML string corresponding to the input data, without whitespace formatting but with an XML header
Exceptions
MAKE-XML-STRING-PARAMETER-EXCEPTIONthe hash passed not not have a single top-level key (either has no keys or more than one)
MAKE-XML-ERRORAn error occurred serializing the Qore data to an XML string
See also
Automatic XML Serialization and Deserialization
Deprecated:
use make_xml(); camel-case function names were deprecated in xml 1.3

◆ parse_xml()

hash Qore::Xml::parse_xml ( string  xml,
*int  pflags,
*string  encoding 
)

Parses an XML string and returns a Qore hash structure.

Code Flags:
RET_VALUE_ONLY
Example:
hash h = parse_xml(xmlstr);
Parameters
xmlthe XML string to parse
pflagsXML parsing flags; see XML Parsing Constants for more information
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, all strings in the output hash will have the default encoding
Returns
a Qore hash structure corresponding to the XML input string
Exceptions
PARSE-XML-EXCEPTIONError parsing the XML string
Note
the default is to parse XML as serialized data; to preserve key order in XML strings for higher fidelity to the original string when serializing back to XML, use the XPF_PRESERVE_ORDER flag when parsing
use the XPF_ADD_COMMENTS to process XML comments and put them in hash as elements with '^comment^' key
See also
Automatic XML Serialization and Deserialization
Since
xml 1.3 as a replacement for deprecated camel-case parseXML() and parseXMLAsData()

◆ parse_xml_with_dtd()

hash Qore::Xml::parse_xml_with_dtd ( string  xml,
string  dtd,
*int  pflags,
*string  encoding 
)

Parses an XML string, validates the XML string against a DTD string, and returns a Qore hash structure.

Code Flags:
RET_VALUE_ONLY
Example:
hash h = parse_xml_with_dtd(xml, dtd);

If any errors occur parsing the DTD string, parsing the XML string, or validating the XML against the DTD, 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.

Parameters
xmlthe XML string to parse
dtdthe DTD string to use to validate the XML string
pflagsXML parsing flags; see XML Parsing Constants for more information
encodingan optional string giving the string encoding of any strings output; if this parameter is missing, the any strings output in the output hash will have UTF-8 encoding
Returns
a Qore hash structure corresponding to the input
Exceptions
PARSE-XML-EXCEPTIONerror parsing the XML string
DTD-SYNTAX-ERRORinvalid DTD string
DTD-VALIDATION-ERRORthe DTD did not pass validation
See also
Since
xml 1.4

◆ parse_xml_with_relaxng()

hash Qore::Xml::parse_xml_with_relaxng ( string  xml,
string  relaxng,
*int  pflags,
*string  encoding 
)

Parses an XML string, validates the XML string against a RelaxNG schema string, and returns a Qore hash structure.

Code Flags:
RET_VALUE_ONLY
Example:
hash h = parse_xml_with_relaxng(xml, relaxng);

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.

The availability of this function depends on the presence of libxml2's xmlTextReaderRelaxNGSetSchema() function when the xml module was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHRELAXNG before running this function.

Parameters
xmlthe XML string to parse
relaxngthe RelaxNG schema string to use to validate the XML string
pflagsXML parsing flags; see XML Parsing Constants for more information
encodingan optional string giving the string encoding of any strings output; if this parameter is missing, the any strings output in the output hash will have UTF-8 encoding
Returns
a Qore hash structure corresponding to the input
Exceptions
PARSE-XML-EXCEPTIONerror parsing the XML string
RELAXNG-SYNTAX-ERRORinvalid RelaxNG string
RELAXNG-VALIDATION-ERRORthe XML did not pass RelaxNG schema validation
MISSING-FEATURE-ERRORthis exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHRELAXNG before calling this function
See also

◆ parse_xml_with_schema()

hash Qore::Xml::parse_xml_with_schema ( string  xml,
string  xsd,
*int  pflags,
*string  encoding 
)

Parses an XML string, validates the XML string against an XSD schema string, and returns a Qore hash structure.

Code Flags:
RET_VALUE_ONLY
Example:
hash h = parse_xml_with_schema(xml, xsd);

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.

The availability of this function depends on the presence of libxml2's xmlTextReaderSetSchema() function when the xml module was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHSCHEMA before running this function.

Parameters
xmlthe XML string to parse
xsdthe XSD schema string to use to validate the XML string
pflagsXML parsing flags; see XML Parsing Constants for more information
encodingan optional string giving the string encoding of any strings output; if this parameter is missing, the any strings output in the output hash will have UTF-8 encoding
Returns
a Qore hash structure corresponding to the input
Exceptions
PARSE-XML-EXCEPTIONerror parsing the XML string
XSD-SYNTAX-ERRORinvalid XSD string
XSD-VALIDATION-ERRORthe XML did not pass schema validation
MISSING-FEATURE-ERRORthis exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHSCHEMA before calling this function
See also
Since
xml 1.3 as a replacement for deprecated camel-case parseXMLWithSchema() and parseXMLAsDataWithSchema()

◆ parseXML() [1/2]

hash Qore::Xml::parseXML ( string  xml,
*string  encoding 
)

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.

This function should only be used when it is important to maintain the XML element order in the resulting Qore data structure (for example, when the data must be re-serialized to an XML string and the element order within a subelement must be maintained), for example, when parsing and reserializing an OSX property list in XML format. In all other cases, parseXMLAsData() should be used instead.

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
xmlthe XML string to parse
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, all strings in the output hash will have the default encoding
Returns
a Qore hash structure corresponding to the XML input string
Exceptions
PARSE-XML-EXCEPTIONError parsing the XML string
See also
Automatic XML Serialization and Deserialization
Deprecated:
use parse_xml(); camel-case function names were deprecated in xml 1.3

◆ parseXML() [2/2]

nothing Qore::Xml::parseXML ( )

This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters.

Code Flags:
RUNTIME_NOOP, DEPRECATED

◆ parseXMLAsData() [1/2]

hash Qore::Xml::parseXMLAsData ( string  xml,
*string  encoding 
)

Parses an XML string as data (does not necessarily preserve key order) and returns a Qore hash structure.

This function does not preserve hash order with out-of-order duplicate keys; all duplicate keys are collapsed to the same list.

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().

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
xmlthe XML string to parse
encodingan optional string giving the encoding for the output XML string; if this parameter is missing, all strings in the output hash will have the default encoding
Returns
a Qore hash structure corresponding to the XML input string
Exceptions
PARSE-XML-EXCEPTIONError parsing the XML string
See also
Deprecated:
use parse_xml(); camel-case function names were deprecated in xml 1.3

◆ parseXMLAsData() [2/2]

nothing Qore::Xml::parseXMLAsData ( )

This is a variant that is basically a noop, included for backwards-compatibility for functions that ignored type errors in the calling parameters.

Code Flags:
RUNTIME_NOOP, DEPRECATED

◆ parseXMLAsDataWithRelaxNG()

hash Qore::Xml::parseXMLAsDataWithRelaxNG ( string  xml,
string  relaxng,
*string  encoding 
)

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.

The availability of this function depends on the presence of libxml2's xmlTextReaderRelaxNGSetSchema() function when the xml module was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHRELAXNG before running this function.

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
xmlthe XML string to parse
relaxngthe RelaxNG schema string to use to validate the XML string
encodingan optional string giving the string encoding of any strings output; if this parameter is missing, the any strings output in the output hash will have UTF-8 encoding
Returns
a Qore hash structure corresponding to the input
Exceptions
PARSE-XML-EXCEPTIONerror parsing the XML string
RELAXNG-SYNTAX-ERRORinvalid RelaxNG string
RELAXNG-VALIDATION-ERRORthe XML did not pass RelaxNG schema validation
MISSING-FEATURE-ERRORthis exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHRELAXNG before calling this function
Deprecated:
use parse_xml_with_relaxng(); camel-case function names were deprecated in xml 1.3

◆ parseXMLAsDataWithSchema()

hash Qore::Xml::parseXMLAsDataWithSchema ( string  xml,
string  xsd,
*string  encoding 
)

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.

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.

The availability of this function depends on the presence of libxml2's xmlTextReaderSetSchema() function when the xml module was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHSCHEMA before running this function.

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
xmlthe XML string to parse
xsdthe XSD schema string to use to validate the XML string
encodingan optional string giving the string encoding of any strings output; if this parameter is missing, the any strings output in the output hash will have UTF-8 encoding
Returns
a Qore hash structure corresponding to the input
Exceptions
PARSE-XML-EXCEPTIONerror parsing the XML string
XSD-SYNTAX-ERRORinvalid XSD string
XSD-VALIDATION-ERRORthe XML did not pass schema validation
MISSING-FEATURE-ERRORthis exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHSCHEMA before calling this function
Deprecated:
use parse_xml_with_schema(); camel-case function names were deprecated in xml 1.3

◆ parseXMLWithRelaxNG()

hash Qore::Xml::parseXMLWithRelaxNG ( string  xml,
string  relaxng,
*string  encoding 
)

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.

The availability of this function depends on the presence of libxml2's xmlTextReaderRelaxNGSetSchema() function when the xml module was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHRELAXNG before running this function.

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
xmlthe XML string to parse
relaxngthe RelaxNG schema string to use to validate the XML string
encodingan optional string giving the string encoding of any strings output; if this parameter is missing, the any strings output in the output hash will have UTF-8 encoding
Returns
a Qore hash structure corresponding to the input
Exceptions
PARSE-XML-EXCEPTIONerror parsing the XML string
RELAXNG-SYNTAX-ERRORinvalid RelaxNG string
RELAXNG-VALIDATION-ERRORthe XML did not pass RelaxNG schema validation
MISSING-FEATURE-ERRORthis exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHRELAXNG before calling this function
Deprecated:
use parse_xml_with_relaxng(); camel-case function names were deprecated in xml 1.3

◆ parseXMLWithSchema()

hash Qore::Xml::parseXMLWithSchema ( string  xml,
string  xsd,
*string  encoding 
)

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.

The availability of this function depends on the presence of libxml2's xmlTextReaderSetSchema() function when the xml module was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHSCHEMA before running this function.

Code Flags:
RET_VALUE_ONLY, DEPRECATED
Parameters
xmlthe XML string to parse
xsdthe XSD schema string to use to validate the XML string
encodingan optional string giving the string encoding of any strings output; if this parameter is missing, the any strings output in the output hash will have UTF-8 encoding
Returns
a Qore hash structure corresponding to the input
Exceptions
PARSE-XML-EXCEPTIONerror parsing the XML string
XSD-SYNTAX-ERRORinvalid XSD string
XSD-VALIDATION-ERRORthe XML did not pass schema validation
MISSING-FEATURE-ERRORthis exception is thrown when the function is not available; for maximum portability, check the constant HAVE_PARSEXMLWITHSCHEMA before calling this function
Deprecated:
use parse_xml_with_schema(); camel-case function names were deprecated in xml 1.3