4.32. Xml::XmlNode Class

The XmlNode class provides information about the components of an XML document. This class currently cannot be constructed manually, but rather can only be returned by the XmlDoc class. It is possible that future versions of Qore will remove this restriction.

Table 4.1019. XmlNode Class Method Overview

Method

Except?

Description

XmlNode::constructor()

Y

Cannot be called manually; throws an exception.

XmlNode::destructor()

N

Destroys the XmlNode object.

XmlNode::copy()

N

Creates an independent copy of the XmlNode object.

XmlNode::childElementCount()

N

Returns the number of child elements of the XmlNode.

XmlNode::getSpacePreserve()

N

Returns the space-preserving behavior of the XmlNode object.

XmlNode::getElementType()

N

Returns the type of the XmlNode object; for possible values see XML Element Type Constants.

XmlNode::getElementTypeName()

N

Returns the name of the type of the XmlNode object; for possible values see the ElementTypeMap constant.

XmlNode::firstElementChild()

N

Returns an XmlNode object for the first child of the current XmlNode object that is an XML element, or NOTHING if there is none.

XmlNode::getLastChild()

N

Returns an XmlNode object for the last child of the current XmlNode object, or NOTHING if there is none.

XmlNode::lastElementChild()

N

Returns an XmlNode object for the last child of the current XmlNode object that is an XML element, or NOTHING if there is none.

XmlNode::nextElementSibling()

N

Returns an XmlNode object for the next element at the same level of the current XmlNode object, or NOTHING if there is none.

XmlNode::previousElementSibling()

N

Returns an XmlNode object for the previous element at the same level of the current XmlNode object, or NOTHING if there is none.

XmlNode::getPath()

N

Returns a string representing a structured path for the current node.

XmlNode::getNsProp()

Y

Returns the value of the given property anchored in the given namespace, or NOTHING if no such property exists in the current XmlNode.

XmlNode::getProp()

Y

Returns the value of the given property, or NOTHING if no such property exists in the current XmlNode.

XmlNode::getContent()

N

Returns a string of the content of the current node.

XmlNode::getName()

N

Returns the name of the current node.

XmlNode::getLang()

N

Returns the language of the current node, determined by the value of the xml:lang attribute of this node or of the nearest ancestor. If no such property is available, then NOTHING is returned.

XmlNode::isText()

N

Returns True if the node is a text node, False if not.

XmlNode::isBlank()

N

Returns True if the node is empty or whitespace only, False if not.

XmlNode::getXML()

N

Returns XML corresponding to the current node and all its children.


4.32.1. XmlNode::constructor()

Synopsis

Cannot be called manually; throws an exception.

Usage
XmlNode::constructor()
Example
$xmlnode = new XmlNode();

Table 4.1020. Arguments for XmlNode::constructor()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1021. Return Values for XmlNode::constructor()

Return Type

Description

n/a

Currently cannot be used; an exception will be thrown if called manually.


Table 4.1022. Exceptions thrown by XmlNode::constructor()

err

desc

XMLNODE-CONSTRUCTOR-ERROR

XmlNode objects cannot be constructed manually


4.32.2. XmlNode::destructor()

Synopsis

Destroys the XmlNode object.

Usage
delete lvalue
Example
delete $xmlnode;

4.32.3. XmlNode::copy()

Synopsis

Creates an independent copy of the XmlNode object.

Usage
XmlNode::copy()
Example
$value = $xmlnode.copy();

Table 4.1023. Return Values for XmlNode::copy()

Return Type

Description

XmlNode

a copy of the current object


4.32.4. XmlNode::childElementCount()

Synopsis

Returns the number of child elements of the XmlNode.

Usage
XmlNode::childElementCount()
Example
$value = $xmlnode.childElementCount();

Table 4.1024. Arguments for XmlNode::childElementCount()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1025. Return Values for XmlNode::childElementCount()

Return Type

Description

Integer

the number of child elements of the XmlNode


4.32.5. XmlNode::getSpacePreserve()

Synopsis

Returns the space-preserving behavior of the XmlNode object.

Usage
XmlNode::getSpacePreserve()
Example
$value = $xmlnode.getSpacePreserve();

Table 4.1026. Arguments for XmlNode::getSpacePreserve()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1027. Return Values for XmlNode::getSpacePreserve()

Return Type

Description

Integer

The space-preserving behavior of the XmlNode: -1 = xml:space is not inherited, 0 = default, 1 = preserve


4.32.6. XmlNode::getElementType()

Synopsis

Returns the type of the XmlNode object; for possible values see XML Element Type Constants.

Usage
XmlNode::getElementType()
Example
$value = $xmlnode.getElementType();

Table 4.1028. Arguments for XmlNode::getElementType()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1029. Return Values for XmlNode::getElementType()

Return Type

Description

Integer

the type of the XmlNode object; for possible values see XML Element Type Constants


4.32.7. XmlNode::getElementTypeName()

Synopsis

Returns the name of the type of the XmlNode object; for possible values see the ElementTypeMap constant.

Usage
XmlNode::getElementTypeName()
Example
$value = $xmlnode.getElementTypeName();

Table 4.1030. Arguments for XmlNode::getElementTypeName()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1031. Return Values for XmlNode::getElementTypeName()

Return Type

Description

String

the name of the type of the XmlNode object; for possible values see the ElementTypeMap constant


4.32.8. XmlNode::firstElementChild()

Synopsis

Returns an XmlNode object for the first child of the current XmlNode object that is an XML element, or NOTHING if there is none.

Usage
XmlNode::firstElementChild()
Example
$value = $xmlnode.firstElementChild();

Table 4.1032. Arguments for XmlNode::firstElementChild()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1033. Return Values for XmlNode::firstElementChild()

Return Type

Description

XmlNode or NOTHING

returns an XmlNode object for the first element child of the current XmlNode object, or NOTHING if there is none


4.32.9. XmlNode::getLastChild()

Synopsis

Returns an XmlNode object for the last child of the current XmlNode object, or NOTHING if there is none.

Usage
XmlNode::getLastChild()
Example
$value = $xmlnode.getLastChild();

Table 4.1034. Arguments for XmlNode::getLastChild()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1035. Return Values for XmlNode::getLastChild()

Return Type

Description

XmlNode or NOTHING

returns an XmlNode object for the last child of the current XmlNode object, or NOTHING if there is none


4.32.10. XmlNode::lastElementChild()

Synopsis

Returns an XmlNode object for the last child of the current XmlNode object that is an XML element, or NOTHING if there is none.

Usage
XmlNode::lastElementChild()
Example
$value = $xmlnode.lastElementChild();

Table 4.1036. Arguments for XmlNode::lastElementChild()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1037. Return Values for XmlNode::lastElementChild()

Return Type

Description

XmlNode or NOTHING

returns an XmlNode object for the last element child of the current XmlNode object, or NOTHING if there is none


4.32.11. XmlNode::nextElementSibling()

Synopsis

Returns an XmlNode object for the next element at the same level of the current XmlNode object, or NOTHING if there is none.

Usage
XmlNode::nextElementSibling()
Example
$value = $xmlnode.nextElementSibling();

Table 4.1038. Arguments for XmlNode::nextElementSibling()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1039. Return Values for XmlNode::nextElementSibling()

Return Type

Description

XmlNode or NOTHING

returns an XmlNode object for the next element at the same level of the current XmlNode object, or NOTHING if there is none


4.32.12. XmlNode::previousElementSibling()

Synopsis

Returns an XmlNode object for the previous element at the same level of the current XmlNode object, or NOTHING if there is none.

Usage
XmlNode::previousElementSibling()
Example
$value = $xmlnode.previousElementSibling();

Table 4.1040. Arguments for XmlNode::previousElementSibling()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1041. Return Values for XmlNode::previousElementSibling()

Return Type

Description

XmlNode or NOTHING

returns an XmlNode object for the previous element at the same level of the current XmlNode object, or NOTHING if there is none


4.32.13. XmlNode::getPath()

Synopsis

Returns a string representing a structured path for the current node.

Usage
XmlNode::getPath()
Example
$value = $xmlnode.getPath();

Table 4.1042. Arguments for XmlNode::getPath()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1043. Return Values for XmlNode::getPath()

Return Type

Description

String

a string representing a structured path for the current node


4.32.14. XmlNode::getNsProp()

Synopsis

Returns the value of the given property anchored in the given namespace, or NOTHING if no such property exists in the current XmlNode.

Usage
XmlNode::getNsProp(prop, namespace)
Example
$value = $xmlnode.getNsProp($prop, $namespace);

Table 4.1044. Arguments for XmlNode::getNsProp()

Argument

Type

Description

prop

String

The name of the property to retrieve

namespace

String

The name of the namespace of the property


Table 4.1045. Return Values for XmlNode::getNsProp()

Return Type

Description

String

the value of the property or NOTHING if it does not exist


Table 4.1046. Exceptions thrown by XmlNode::getNsProp()

err

desc

XMLNODE-GETNSPROP-ERROR

missing or invalid argument


4.32.15. XmlNode::getProp()

Synopsis

Returns the value of the given property, or NOTHING if no such property exists in the current XmlNode.

Usage
XmlNode::getProp(prop)
Example
$value = $xmlnode.getProp($prop);

Table 4.1047. Arguments for XmlNode::getProp()

Argument

Type

Description

prop

String

The name of the property to retrieve


Table 4.1048. Return Values for XmlNode::getProp()

Return Type

Description

String

the value of the property or NOTHING if it does not exist


Table 4.1049. Exceptions thrown by XmlNode::getProp()

err

desc

XMLNODE-GETPROP-ERROR

missing or invalid argument


4.32.16. XmlNode::getContent()

Synopsis

Returns a string of the content of the current node.

Usage
XmlNode::getContent()
Example
$value = $xmlnode.getContent();

Table 4.1050. Arguments for XmlNode::getContent()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1051. Return Values for XmlNode::getContent()

Return Type

Description

String

a string of the content of the current node


4.32.17. XmlNode::getName()

Synopsis

Returns the name of the current node.

Usage
XmlNode::getName()
Example
$value = $xmlnode.getName();

Table 4.1052. Arguments for XmlNode::getName()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1053. Return Values for XmlNode::getName()

Return Type

Description

String

the name of the current node


4.32.18. XmlNode::getLang()

Synopsis

Returns the language of the current node, determined by the value of the xml:lang attribute of this node or of the nearest ancestor. If no such property is available, then NOTHING is returned.

Usage
XmlNode::getLang()
Example
$value = $xmlnode.getLang();

Table 4.1054. Arguments for XmlNode::getLang()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1055. Return Values for XmlNode::getLang()

Return Type

Description

String

the language of the current node, determined by the value of the xml:lang attribute of this node or of the nearest ancestor. If no such property is available, then NOTHING is returned.


4.32.19. XmlNode::isText()

Synopsis

Returns True if the node is a text node, False if not.

Usage
XmlNode::isText()
Example
$value = $xmlnode.isText();

Table 4.1056. Arguments for XmlNode::isText()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1057. Return Values for XmlNode::isText()

Return Type

Description

Boolean

True if the node is a text node, False if not


4.32.20. XmlNode::isBlank()

Synopsis

Returns True if the node is empty or whitespace only, False if not.

Usage
XmlNode::isBlank()
Example
$value = $xmlnode.isBlank();

Table 4.1058. Arguments for XmlNode::isBlank()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1059. Return Values for XmlNode::isBlank()

Return Type

Description

Boolean

True if the node is empty or whitespace only, False if not


4.32.21. XmlNode::getXML()

Synopsis

Returns XML corresponding to the current node and all its children.

Usage
XmlNode::getXML()
Example
$value = $xmlnode.getXML();

Table 4.1060. Arguments for XmlNode::getXML()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.1061. Return Values for XmlNode::getXML()

Return Type

Description

String

XML corresponding to the current node and all its children