OpenWGA 7.9 - TMLScript reference

WGA » WGA.Xml
Method :

xpathList(domobject, xpath [, namespaces])

On object WGA.Xml
Usage Executes an XPath expression on some XML text or JavaBean, returning a list
Description
This function always returns lists. If the xpath expression matches only a single values it will return it as single element in a list. If you only want to retrieve single values use xpath().

It accepts the following types of DOM object:

  • An XML string. The given XML text is parsed. Then the XPath expression is executed on the resulting DOM document at root level. 
  • Any DOM node from an XML document parsed by parse() or load(). The XPath expression is executed on the given node.
  • A JavaBean. The XPath expression is used to identify bean properties. The result is the value that is stored on the requested bean property. This uses the Apache library JXPath under the hood. See their documentation for details how XPath is used to browse JavaBeans.

If your DOM contains nodes belonging to an XML namespace you will need to define prefixes for those namespaces by using argument "namespaces" and use those prefixes in the XPath expression on these nodes if you want to query them.

For backward compatibility there still is a global function "xpathList()" available whose use is discouraged since OpenWGA 5.3.

Parameters

domobject (String, Java object):

The DOM object on which the XPath is to be executed. See the description for valid types.

xpath (String):

XPath expression to execute

namespaces (Lookup table, optional):

Determines XML namespace prefixes to be used inside the XPath expression. Keys are prefixes, values are namespace URIs. The prefixes do not need to match prefixes that that may be present in the parsed XML. DOM elements that are specified in the XPath expression without prefixes determined here are regarded to be of the default namespace.

Return value Variant 1: List of results of the expression, either the text of text nodes or attributes, or DOM4J node objects (org.dom4j.Node)

Variant 2: List of custom values retrieved from the JavaBean
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
    portletevent