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.739. XmlNode Class Method Overview
|
Method |
Except? |
Description |
|---|---|---|
|
Y |
Cannot be called manually; throws an exception. | |
|
N |
Destroys the XmlNode object. | |
|
N |
Creates an independent copy of the XmlNode object. | |
|
|
N |
Returns the number of child elements of the XmlNode. |
|
|
N |
Returns the space-preserving behavior of the XmlNode object. |
|
|
N | Returns the type of the XmlNode object; for possible values see XML Element Type Constants. |
|
|
N | Returns the name of the type of the XmlNode object if possible, NOTHING if not; for possible values see the ElementTypeMap constant. |
|
|
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. |
|
|
N |
Returns an XmlNode object for the last child of the current XmlNode object, or NOTHING if there is none. |
|
|
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. |
|
|
N |
Returns an XmlNode object for the next element at the same level of the current XmlNode object, or NOTHING if there is none. |
|
|
N |
Returns an XmlNode object for the previous element at the same level of the current XmlNode object, or NOTHING if there is none. |
|
|
Y |
Returns a string representing a structured path for the current node. |
|
|
Y |
Returns the value of the given property anchored in the given namespace as a string, or NOTHING if no such property exists in the current XmlNode. |
|
|
Y |
Returns the value of the given property as a string, or NOTHING if no such property exists in the current XmlNode. |
|
|
N |
Returns a string of the content of the current node or NOTHING if no content is available. |
|
|
N |
Returns the name of the current node or NOTHING if no name is available. |
|
|
N |
Returns the language of the current node, determined by the value of the |
|
|
N |
Returns |
|
|
N |
Returns |
|
|
N |
Returns XML corresponding to the current node and all its children or NOTHING if no data is available. |
Cannot be called manually; throws an exception.
Table 4.740. Exceptions thrown by XmlNode::constructor()
|
err |
desc |
|---|---|
|
|
XmlNode objects cannot be constructed manually |
Creates an independent copy of the XmlNode object.
my XmlNode $value = $xmlnode.copy();
Returns the number of child elements of the XmlNode.
XmlNode::childElementCount() returns int
$value = $xmlnode.childElementCount();
Table 4.741. Return Values for XmlNode::childElementCount()
|
Return Type |
Description |
|---|---|
|
the number of child elements of the XmlNode |
Returns the space-preserving behavior of the XmlNode object.
XmlNode::getSpacePreserve() returns int
$value = $xmlnode.getSpacePreserve();
Table 4.742. Return Values for XmlNode::getSpacePreserve()
|
Return Type |
Description |
|---|---|
|
The space-preserving behavior of the XmlNode: -1 = xml:space is not inherited, 0 = default, 1 = preserve |
Returns the type of the XmlNode object; for possible values see XML Element Type Constants.
XmlNode::getElementType() returns int
$value = $xmlnode.getElementType();
Table 4.743. Return Values for XmlNode::getElementType()
|
Return Type |
Description |
|---|---|
|
the type of the XmlNode object; for possible values see XML Element Type Constants |
Returns the name of the type of the XmlNode object; for possible values see the ElementTypeMap constant.
XmlNode::getElementTypeName() returns any
$value = $xmlnode.getElementTypeName();
Table 4.744. Return Values for XmlNode::getElementTypeName()
|
Return Type |
Description |
|---|---|
|
the name of the type of the XmlNode object; for possible values see the ElementTypeMap constant |
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::firstElementChild() returns any
$value = $xmlnode.firstElementChild();
Returns an XmlNode object for the last child of the current XmlNode object, or NOTHING if there is none.
XmlNode::getLastChild() returns any
$value = $xmlnode.getLastChild();
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::lastElementChild() returns any
$value = $xmlnode.lastElementChild();
Returns an XmlNode object for the next element at the same level of the current XmlNode object, or NOTHING if there is none.
XmlNode::nextElementSibling() returns any
$value = $xmlnode.nextElementSibling();
Returns an XmlNode object for the previous element at the same level of the current XmlNode object, or NOTHING if there is none.
XmlNode::previousElementSibling() returns any
$value = $xmlnode.previousElementSibling();
Returns a string representing a structured path for the current node.
XmlNode::getPath() returns string
$value = $xmlnode.getPath();
Table 4.750. Return Values for XmlNode::getPath()
|
Return Type |
Description |
|---|---|
|
a string representing a structured path for the current node |
Returns the value of the given property anchored in the given namespace, or NOTHING if no such property exists in the current XmlNode.
XmlNode::getNsProp(string $prop, string $ns) returns any
$value = $xmlnode.getNsProp($prop, $namespace);
Table 4.753. Exceptions thrown by XmlNode::getNsProp()
|
err |
desc |
|---|---|
|
|
missing or invalid argument |
Returns the value of the given property, or NOTHING if no such property exists in the current XmlNode.
XmlNode::getProp(string $prop) returns any
$value = $xmlnode.getProp($prop);
Table 4.754. Arguments for XmlNode::getProp()
Argument | Description |
|---|---|
| The name of the property to retrieve |
Table 4.756. Exceptions thrown by XmlNode::getProp()
|
err |
desc |
|---|---|
|
|
missing or invalid argument |
Returns a string of the content of the current node or NOTHING if there is none.
XmlNode::getContent() returns any
$value = $xmlnode.getContent();
Returns the name of the current node or NOTHING if no name is available.
XmlNode::getName() returns any
$value = $xmlnode.getName();
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::getLang() returns any
$value = $xmlnode.getLang();
Returns True if the node is a text node, False if not.
XmlNode::isText() returns bool
$value = $xmlnode.isText();
Table 4.760. Return Values for XmlNode::isText()
|
Return Type |
Description |
|---|---|
|
True if the node is a text node, |
Returns True if the node is empty or whitespace only, False if not.
XmlNode::isBlank() returns bool
$value = $xmlnode.isBlank();
Table 4.761. Return Values for XmlNode::isBlank()
|
Return Type |
Description |
|---|---|
|
True if the node is empty or whitespace only, |
Returns a string containing XML corresponding to the current node and all its children or NOTHING if no information is available.
XmlNode::getXML() returns any
$value = $xmlnode.getXML();