Qore xml Module  1.6.0
Qore::Xml::XmlNode Class Reference

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

Public Member Methods

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

◆ childElementCount()

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:
int val = n.childElementCount();

◆ constructor()

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

cannot be called manually; throws an exception

Exceptions
XMLNODE-CONSTRUCTOR-ERRORthis class cannot be constructed directly

◆ copy()

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

Returns a copy of the current object.

Returns
a copy of the current object
Example:
XmlNode xncopy = xn.copy();

◆ firstElementChild()

*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:
*XmlNode xn = node.firstElementChild();

◆ getContent()

*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:
*string value = xmlnode.getContent();

◆ getElementType()

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:
int val = n.getElementType();

◆ getElementTypeName()

*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:
*string name = n.getElementTypeName();

◆ getLang()

*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:
*string lang = xmlnode.getLang();

◆ getLastChild()

*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:
*XmlNode xn = node.getLastChild();

◆ getName()

*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:
*string name = xmlnode.getName();

◆ getNsProp()

*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
propthe name of the property
nsthe 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:
*string val = node.getNsProp(prop, ns);

◆ getPath()

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:
string path = node.getPath();
Exceptions
XMLNODE-GET-PATH-ERRORan error occurred retrieving the node's path

◆ getProp()

*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
propthe name of the property
Returns
the value of the given property, or NOTHING if no such property exists in the current XmlNode
Example:
*string val = node.getProp(prop);

◆ getSpacePreserve()

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:
int val = n.getSpacePreserve();

◆ getXML()

*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:
*string value = xmlnode.getXML();

◆ isBlank()

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:
bool b = xmlnode.isBlank();

◆ isText()

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:
bool b = xmlnode.isText();

◆ lastElementChild()

*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:
*XmlNode xn = node.lastElementChild();

◆ nextElementSibling()

*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:
*XmlNode xn = node.nextElementSibling();

◆ previousElementSibling()

*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:
*XmlNode xn = node.previousElementSibling();

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