Qore::Xml::XmlNode Class Reference

The XmlNode class provides information about the components of an XML document. More...

## Public Member Functions

int | childElementCount ()
| Returns the number of child elements of the XmlNode. More...
| constructor ()
| cannot be called manually; throws an exception More...
| copy ()
| Returns a copy of the current object. More...
*XmlNode | firstElementChild ()
| Returns an XmlNode object for the first child of the current XmlNode object that is an XML element, or `NOTHING` if there is none. More...
*string | getContent ()
| Returns a string of the content of the current node or `NOTHING` if there is none. More...
int | getElementType ()
| Returns the type of the XmlNode object. More...
*string | getElementTypeName ()
| Returns the name of the type of the XmlNode object. More...
*string | getLang ()
| 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. More...
*XmlNode | getLastChild ()
| Returns an XmlNode object for the last child of the current XmlNode object, or `NOTHING` if there is none. More...
*string | getName ()
| Returns the name of the current node or `NOTHING` if no name is available. More...
*string | getNsProp (string prop, string ns)
| Returns the value of the given property anchored in the given namespace, or `NOTHING` if no such property exists in the current XmlNode. More...
string | getPath ()
| Returns a string representing a structured path for the current node. More...
*string | getProp (string prop)
| Returns the value of the given property, or `NOTHING` if no such property exists in the current XmlNode. More...
int | getSpacePreserve ()
| Searches the space preserving behaviour of the XmlNode object, i.e. the values of the `xml:space` attribute or the one carried by the nearest ancestor. More...
*string | getXML ()
| Returns a string containing XML corresponding to the current node and all its children or `NOTHING` if no information is available. More...
bool | isBlank ()
| Returns `True` if the node is empty or whitespace only, `False` if not. More...
bool | isText ()
| Returns `True` if the node is a text node, `False` if not. More...
*XmlNode | lastElementChild ()
| Returns an XmlNode object for the last child of the current XmlNode object that is an XML element, or `NOTHING` if there is none. More...
*XmlNode | nextElementSibling ()
| Returns an XmlNode object for the next element at the same level of the current XmlNode object, or `NOTHING` if there is none. More...
*XmlNode | previousElementSibling ()
| Returns an XmlNode object for the previous element at the same level of the current XmlNode object, or `NOTHING` if there is none. More...

## Detailed Description

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 the xml module will remove this restriction.

## Member Function Documentation

int Qore::Xml::XmlNode::childElementCount | ( |  | ) |

Returns the number of child elements of the XmlNode.

Returns
  the number of child elements of the XmlNode

Code Flags:
  CONSTANT

Example:
  my int $val = $n.childElementCount();

Qore::Xml::XmlNode::constructor | ( |  | ) |

cannot be called manually; throws an exception

Exceptions

  XMLNODE-CONSTRUCTOR-ERROR | this class cannot be constructed directly

Qore::Xml::XmlNode::copy | ( |  | ) |

Returns a copy of the current object.

Returns
  a copy of the current object

Example:
  my XmlNode $xncopy = $xn.copy();

*XmlNode Qore::Xml::XmlNode::firstElementChild | ( |  | ) |

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

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

Code Flags:
  CONSTANT

Example:
  my *XmlNode $xn = $node.firstElementChild();

*string Qore::Xml::XmlNode::getContent | ( |  | ) |

Returns a string of the content of the current node or `NOTHING` if there is none.

Returns
  a string of the content of the current node or `NOTHING` if there is none

Code Flags:
  CONSTANT

Example:
  my *string $value = $xmlnode.getContent();

int Qore::Xml::XmlNode::getElementType | ( |  | ) |

Returns the type of the XmlNode object.

Returns
  the element type as an integer; for possible values see XML Element Type Constants

Code Flags:
  CONSTANT

Example:
  my int $val = $n.getElementType();

*string Qore::Xml::XmlNode::getElementTypeName | ( |  | ) |

Returns the name of the type of the XmlNode object.

Returns
  the name of the type of the XmlNode object; for possible values see the values of the ElementTypeMap; if the type is unknown, then `NOTHING` is returned

Code Flags:
  CONSTANT

Example:
  my *string $name = $n.getElementTypeName();

*string Qore::Xml::XmlNode::getLang | ( |  | ) |

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.

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

Code Flags:
  CONSTANT

Example:
  my *string $lang = $xmlnode.getLang();

*XmlNode Qore::Xml::XmlNode::getLastChild | ( |  | ) |

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

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

Code Flags:
  CONSTANT

Example:
  my *XmlNode $xn = $node.getLastChild();

*string Qore::Xml::XmlNode::getName | ( |  | ) |

Returns the name of the current node or `NOTHING` if no name is available.

Returns
  the name of the current node or `NOTHING` if no name is available

Code Flags:
  CONSTANT

Example:
  my *string $name = $xmlnode.getName();

*string Qore::Xml::XmlNode::getNsProp | ( | string | prop,
|  | string | ns
| ) |  |

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

Code Flags:
  CONSTANT

Parameters

  prop | the name of the property
  ns | the namespace anchoring the property

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

Example:
  my *string $val = $node.getNsProp($prop, $ns);

string Qore::Xml::XmlNode::getPath | ( |  | ) |

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

Returns
  a string representing a structured path for the current node

Code Flags:
  RET_VALUE_ONLY

Example:
  my string $path = $node.getPath();

Exceptions

  XMLNODE-GET-PATH-ERROR | an error occurred retrieving the node's path

*string Qore::Xml::XmlNode::getProp | ( | string | prop | ) |

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

Code Flags:
  CONSTANT

Parameters

  prop | the name of the property

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

Example:
  my *string $val = $node.getProp($prop);

int Qore::Xml::XmlNode::getSpacePreserve | ( |  | ) |

Searches the space preserving behaviour of the XmlNode object, i.e. the values of the `xml:space` attribute or the one carried by the nearest ancestor.

Returns
  -1 if `xml:space` is not inherited, 0 if `"default"`, 1 if `"preserve"`

Code Flags:
  CONSTANT

Example:
  my int $val = $n.getSpacePreserve();

*string Qore::Xml::XmlNode::getXML | ( |  | ) |

Returns a string containing XML corresponding to the current node and all its children or `NOTHING` if no information is available.

Returns
  a string containing XML corresponding to the current node and all its children or `NOTHING` if no information is available

Code Flags:
  CONSTANT

Example:
  my *string $value = $xmlnode.getXML();

bool Qore::Xml::XmlNode::isBlank | ( |  | ) |

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

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

Code Flags:
  CONSTANT

Example:
  my bool $b = $xmlnode.isBlank();

bool Qore::Xml::XmlNode::isText | ( |  | ) |

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

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

Code Flags:
  CONSTANT

Example:
  my bool $b = $xmlnode.isText();

*XmlNode Qore::Xml::XmlNode::lastElementChild | ( |  | ) |

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

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

Code Flags:
  CONSTANT

Example:
  my *XmlNode $xn = $node.lastElementChild();

*XmlNode Qore::Xml::XmlNode::nextElementSibling | ( |  | ) |

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

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

Code Flags:
  CONSTANT

Example:
  my *XmlNode $xn = $node.nextElementSibling();

*XmlNode Qore::Xml::XmlNode::previousElementSibling | ( |  | ) |

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

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

Code Flags:
  CONSTANT

Example:
  my *XmlNode $xn = $node.previousElementSibling();

The documentation for this class was generated from the following file:

- /Users/david/src/qore/git/module-xml/src/QC_XmlNode.dox.h