![]() |
Qore XML Module
1.6.1
|
The XmlReader class allows XML strings to be iterated and parsed piecewise. More...
Public Member Methods | |
| int | attributeCount () |
| Returns the number of attributes of the current node. More... | |
| *string | baseUri () |
Returns the base URI of the node if known, NOTHING if not. More... | |
| constructor (XmlDoc doc) | |
| Creates the XmlReader object based on an XmlDoc object. More... | |
| constructor (string xml) | |
| Creates the XmlReader object based on the string passed; the string will be converted to UTF-8 encoding before parsing if necessary. More... | |
| constructor (Qore::InputStream is, *hash opts) | |
| creates a new XmlReader object from the input stream More... | |
| copy () | |
| Creates an independent copy of the XmlReader object. More... | |
| int | depth () |
| Returns the depth of the node in the tree. More... | |
| *string | encoding () |
Returns the encoding string given in the original XML string or NOTHING if none is given. More... | |
| *string | getAttribute (string attr) |
Returns the value of the attribute matching the qualified name passed, or NOTHING if no such attribute exists in the current XmlReader. More... | |
| *string | getAttributeNs (string attr, string ns) |
Returns the value of the given attribute anchored in the given namespace, or NOTHING if no such attribute exists in the current XmlReader. More... | |
| *string | getAttributeOffset (softint offset=0) |
Returns the value of the attribute with the specified index relative to the containing element, or NOTHING if no such attribute exists in the current XmlReader. More... | |
| *string | getInnerXml () |
Returns an XML string of the contents of the all current node's child nodes and markup, or NOTHING if the current node is neither an element nor an attribute or has no child nodes. More... | |
| *string | getOuterXml () |
Return an XML string of the contents of the current node and all child nodes and markup, or NOTHING if the current node is neither an element nor an attribute or has no child nodes. More... | |
| bool | hasAttributes () |
Returns True if the node has attributes or False if not. More... | |
| bool | hasValue () |
Returns True if the node has a text value or False if not. More... | |
| bool | isDefault () |
Returns True if an attribute node was generated from the default value defined in the DTD or schema, False if not. More... | |
| bool | isEmptyElement () |
Returns True if the current node is empty or False if not. More... | |
| bool | isNamespaceDecl () |
Returns True if the current node is a namespace declaration rather than a regular attribute or False if not. More... | |
| bool | isValid () |
Returns True if the current reader parser context is valid, False if not. More... | |
| *string | localName () |
Returns the local name of the node or NOTHING if no name is available. More... | |
| *string | lookupNamespace () |
Returns the default namespace in the scope of the current element, or NOTHING if none exists. More... | |
| *string | lookupNamespace (string prefix) |
Returns the namespace corresponding to the given prefix in the scope of the current element, or NOTHING if none exists. More... | |
| bool | moveToAttribute (string attr) |
| Moves the position of the current instance to the attribute with the specified qualified name. More... | |
| bool | moveToAttributeNs (string attr, string ns) |
| Moves the position of the current instance to the attribute with the specified local name and namespace URI. More... | |
| bool | moveToAttributeOffset (softint offset) |
| Moves the position of the current instance to the attribute with the specified index relative to the containing element. More... | |
| bool | moveToElement () |
| Moves the position of the current instance to the element node containing the current attribute node. More... | |
| bool | moveToFirstAttribute () |
| Moves the position of the current instance to the first attribute of the current node. More... | |
| bool | moveToNextAttribute () |
| Moves the position of the current instance to the next attribute of the current node. More... | |
| *string | name () |
Returns the qualified name of the node (prefix:LocalName) or NOTHING if no name is available. More... | |
| *string | namespaceUri () |
Returns the URI defining the namespace associated with the node, or NOTHING if not available. More... | |
| bool | next () |
| Moves the position of the current instance to the next node in the tree at the same level, skipping any subtree. More... | |
| int | nodeType () |
| Returns the node type of the current node. More... | |
| *string | nodeTypeName () |
Returns a string giving the node type of the current node or NOTHING if no current node is available. More... | |
| *string | prefix () |
Returns the shorthand reference to the namespace associated with the node, or NOTHING if not available. More... | |
| bool | read () |
| Moves the position of the current instance to the next node in the stream. More... | |
| bool | readSkipWhitespace () |
| the position of the current instance to the next node in the stream, skipping any whitespace nodes More... | |
| nothing | relaxNGValidate (string relaxng) |
| Set a RelaxNG schema for schema validation while parsing the XML document. More... | |
| nothing | schemaValidate (string xsd) |
| Set an XSD schema for schema validation while parsing the XML document. More... | |
| any | toQore (int pflags=XPF_PRESERVE_ORDER) |
| Returns Qore data corresponding to the XML starting at the current node position, maintains element order by mangling node names. More... | |
| any | toQoreData (*int pflags) |
| Returns Qore data corresponding to the XML starting at the current node position, collapses duplicate out of order elements to a list. More... | |
| *string | value () |
Returns the text value of the node or NOTHING if not available. More... | |
| *string | xmlLang () |
Returns the xml:lang scope within which the node resides or NOTHING if there is none. More... | |
| *string | xmlVersion () |
Returns a string giving the XML version of the source document (normally "1.0") or NOTHING if none is present. More... | |
The XmlReader class allows XML strings to be iterated and parsed piecewise.
| int Qore::Xml::XmlReader::attributeCount | ( | ) |
Returns the number of attributes of the current node.
| *string Qore::Xml::XmlReader::baseUri | ( | ) |
| Qore::Xml::XmlReader::constructor | ( | Qore::InputStream | is, |
| *hash | opts | ||
| ) |
creates a new XmlReader object from the input stream
| is | the input stream |
| opts | the following options are accepted:
|
| XML-READER-OPTION-ERROR | error in option hash |
| XML-READER-ERROR | libxml2 returned an error code when creating the XML reader object |
xml_parse_options option is accepted but ignored in this method; XML parsing options can be used in XmlReader::toQore() and XmlReader::toQoreData()| Qore::Xml::XmlReader::constructor | ( | string | xml | ) |
Creates the XmlReader object based on the string passed; the string will be converted to UTF-8 encoding before parsing if necessary.
| XML-READER-ERROR | libxml2 returned an error code when creating the XML reader object (ex: XML string could not be parsed) |
| ENCODING-CONVERSION-ERROR | the string could not be converted to UTF-8 (usually due to an encoding error in the source string) |
| Qore::Xml::XmlReader::constructor | ( | XmlDoc | doc | ) |
| Qore::Xml::XmlReader::copy | ( | ) |
| int Qore::Xml::XmlReader::depth | ( | ) |
| *string Qore::Xml::XmlReader::encoding | ( | ) |
Returns the encoding string given in the original XML string or NOTHING if none is given.
NOTHING if none is given| *string Qore::Xml::XmlReader::getAttribute | ( | string | attr | ) |
Returns the value of the attribute matching the qualified name passed, or NOTHING if no such attribute exists in the current XmlReader.
| attr | the name of the attribute to retrieve |
NOTHING if no such attribute exists in the current XmlReader| *string Qore::Xml::XmlReader::getAttributeNs | ( | string | attr, |
| string | ns | ||
| ) |
Returns the value of the given attribute anchored in the given namespace, or NOTHING if no such attribute exists in the current XmlReader.
| attr | the name of the attribute to retrieve |
| ns | the namespace URI of the attribute |
NOTHING if no such attribute exists in the current XmlReader| *string Qore::Xml::XmlReader::getAttributeOffset | ( | softint | offset = 0 | ) |
Returns the value of the attribute with the specified index relative to the containing element, or NOTHING if no such attribute exists in the current XmlReader.
| offset | the attribute number of the attribute to retrieve relative to the containing element starting from 0 |
NOTHING if no such attribute exists in the current XmlReader| *string Qore::Xml::XmlReader::getInnerXml | ( | ) |
Returns an XML string of the contents of the all current node's child nodes and markup, or NOTHING if the current node is neither an element nor an attribute or has no child nodes.
NOTHING if the current node is neither an element nor an attribute or has no child nodes| *string Qore::Xml::XmlReader::getOuterXml | ( | ) |
Return an XML string of the contents of the current node and all child nodes and markup, or NOTHING if the current node is neither an element nor an attribute or has no child nodes.
NOTHING if the current node is neither an element nor an attribute or has no child nodes| bool Qore::Xml::XmlReader::hasAttributes | ( | ) |
Returns True if the node has attributes or False if not.
True if the node has attributes or False if not| bool Qore::Xml::XmlReader::hasValue | ( | ) |
Returns True if the node has a text value or False if not.
True if the node has a text value or False if not| bool Qore::Xml::XmlReader::isDefault | ( | ) |
Returns True if an attribute node was generated from the default value defined in the DTD or schema, False if not.
True if an attribute node was generated from the default value defined in the DTD or schema, False if not| bool Qore::Xml::XmlReader::isEmptyElement | ( | ) |
Returns True if the current node is empty or False if not.
True if the current node is empty or False if not| bool Qore::Xml::XmlReader::isNamespaceDecl | ( | ) |
Returns True if the current node is a namespace declaration rather than a regular attribute or False if not.
True if the current node is a namespace declaration rather than a regular attribute or False if not| bool Qore::Xml::XmlReader::isValid | ( | ) |
Returns True if the current reader parser context is valid, False if not.
True if the current reader parser context is valid, False if not| *string Qore::Xml::XmlReader::localName | ( | ) |
| *string Qore::Xml::XmlReader::lookupNamespace | ( | ) |
Returns the default namespace in the scope of the current element, or NOTHING if none exists.
NOTHING if none exists| *string Qore::Xml::XmlReader::lookupNamespace | ( | string | prefix | ) |
Returns the namespace corresponding to the given prefix in the scope of the current element, or NOTHING if none exists.
| prefix | the namespace prefix to resolve |
NOTHING if none exists| bool Qore::Xml::XmlReader::moveToAttribute | ( | string | attr | ) |
Moves the position of the current instance to the attribute with the specified qualified name.
If an XML parsing error occurs, an exception is thrown
| attr | the qualified name of the attribute to move to |
True in case of success, False if not found| PARSE-XML-EXCEPTION | error parsing XML |
| bool Qore::Xml::XmlReader::moveToAttributeNs | ( | string | attr, |
| string | ns | ||
| ) |
Moves the position of the current instance to the attribute with the specified local name and namespace URI.
If an XML parsing error occurs, an exception is thrown
| attr | the qualified name of the attribute to move to |
| ns | the namespace URI of the attribute |
True in case of success, False if not found| PARSE-XML-EXCEPTION | error parsing XML |
| bool Qore::Xml::XmlReader::moveToAttributeOffset | ( | softint | offset | ) |
Moves the position of the current instance to the attribute with the specified index relative to the containing element.
If an XML parsing error occurs, an exception is thrown
| offset | the index of the attribute relative to the containing element to move to starting with 0 |
True in case of success, False if not found| PARSE-XML-EXCEPTION | error parsing XML |
| bool Qore::Xml::XmlReader::moveToElement | ( | ) |
Moves the position of the current instance to the element node containing the current attribute node.
If an XML parsing error occurs, an exception is thrown
True in case of success, False if not found| PARSE-XML-EXCEPTION | error parsing XML |
| bool Qore::Xml::XmlReader::moveToFirstAttribute | ( | ) |
Moves the position of the current instance to the first attribute of the current node.
If an XML parsing error occurs, an exception is thrown
True in case of success, False if not found| PARSE-XML-EXCEPTION | error parsing XML |
| bool Qore::Xml::XmlReader::moveToNextAttribute | ( | ) |
Moves the position of the current instance to the next attribute of the current node.
If an XML parsing error occurs, an exception is thrown
True in case of success, False if not found| PARSE-XML-EXCEPTION | error parsing XML |
| *string Qore::Xml::XmlReader::name | ( | ) |
Returns the qualified name of the node (prefix:LocalName) or NOTHING if no name is available.
prefix:LocalName) or NOTHING if no name is available| *string Qore::Xml::XmlReader::namespaceUri | ( | ) |
| bool Qore::Xml::XmlReader::next | ( | ) |
Moves the position of the current instance to the next node in the tree at the same level, skipping any subtree.
If an XML parsing error occurs, an exception is thrown
True in case of success, False if not found| PARSE-XML-EXCEPTION | error parsing XML |
| int Qore::Xml::XmlReader::nodeType | ( | ) |
Returns the node type of the current node.
| *string Qore::Xml::XmlReader::nodeTypeName | ( | ) |
Returns a string giving the node type of the current node or NOTHING if no current node is available.
NOTHING if no current node is available; for possible return values, see the values of the NodeTypeMap| *string Qore::Xml::XmlReader::prefix | ( | ) |
| bool Qore::Xml::XmlReader::read | ( | ) |
Moves the position of the current instance to the next node in the stream.
If an error occurs parsing the XML string, an exception is raised
True if the read was successful, False if there are no more nodes to read| PARSE-XML-EXCEPTION | cannot move to next node due to an error parsing the XML string (exception description string contains details about the error) |
| bool Qore::Xml::XmlReader::readSkipWhitespace | ( | ) |
the position of the current instance to the next node in the stream, skipping any whitespace nodes
If an error occurs parsing the XML string, an exception is raised
True if the read was successful, False if there are no more nodes to read| PARSE-XML-EXCEPTION | cannot move to next node due to an error parsing the XML string (exception description string contains details about the error) |
| nothing Qore::Xml::XmlReader::relaxNGValidate | ( | string | relaxng | ) |
Set a RelaxNG schema for schema validation while parsing the XML document.
This method must be called before the first call to XmlReader::read()
The availability of this method depends on the presence of libxml2's xmlTextReaderRelaxNGValidate() function when the xml module was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHRELAXNG before calling this method.
| relaxng | the RelaxNG schema string to use to validate the XML document |
| RELAXNG-SYNTAX-ERROR | invalid RelaxNG string |
| 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 |
| nothing Qore::Xml::XmlReader::schemaValidate | ( | string | xsd | ) |
Set an XSD schema for schema validation while parsing the XML document.
This method must be called before the first call to XmlReader::read()
The availability of this method depends on the presence of libxml2's xmlTextReaderSetSchema() function when the xml module was compiled; for maximum portability check the constant HAVE_PARSEXMLWITHSCHEMA before calling this method.
| xsd | the XSD schema string to use to validate the XML document |
| XSD-SYNTAX-ERROR | invalid XSD string |
| 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 |
| any Qore::Xml::XmlReader::toQore | ( | int | pflags = XPF_PRESERVE_ORDER | ) |
Returns Qore data corresponding to the XML starting at the current node position, maintains element order by mangling node names.
| pflags | XML parsing flags; see XML Parsing Constants for more information; note that this method assumes XPF_PRESERVE_ORDER for backwards-compatibility |
NOTHING is returned.| any Qore::Xml::XmlReader::toQoreData | ( | *int | pflags | ) |
Returns Qore data corresponding to the XML starting at the current node position, collapses duplicate out of order elements to a list.
| pflags | XML parsing flags; see XML Parsing Constants for more information |
NOTHING is returned.| *string Qore::Xml::XmlReader::value | ( | ) |
Returns the text value of the node or NOTHING if not available.
NOTHING if not available| *string Qore::Xml::XmlReader::xmlLang | ( | ) |
| *string Qore::Xml::XmlReader::xmlVersion | ( | ) |