JavaScript API

XPathHelper: (xh)

class XPathHelper(currentPath)

exported from xpath-helper

XPathHelper provides a simple and chainnable API to build complicated XPath queries without the hassle. After building your XPath query, call the method toString() to get the corresponding XPath string.

Creates an instance of XPathHelper.

Arguments
  • currentPath (string[]()) –

XPathHelper.empty()

Empties the current path.

XPathHelper.getAncestor(filter)

Selects the nodes filtered by filter, that are ancestors, or the parent, and the parent’s parent, and so on, to the node in reference.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getAncestorBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, that are ancestors, or the parent, and the parent’s parent, and so on, to the node in reference.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getAncestorByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, that are ancestors, or the parent, and the parent’s parent, and so on, to the node in reference.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getAncestorOrSelf(filter)

Selects the nodes filtered by filter, that are ancestors, or the parent, and the parent’s parent, and so on, including the node in reference.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getAncestorOrSelfBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, that are ancestors, or the parent, and the parent’s parent, and so on, including the node in reference.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getAncestorOrSelfByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, that are ancestors, or the parent, and the parent’s parent, and so on, including the node in reference.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getChild(filter)

Selects the nodes filtered by filter immediately below the node in reference.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getChildBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, immediately below the node in reference.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getChildByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, immediately below the node in reference.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getDescendant(filter)

Selects the nodes filtered by filter, below the node in reference no matter the depth.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getDescendantBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, below the node in reference no matter the depth.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getDescendantByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, below the node in reference no matter the depth.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getDescendantOrSelf(filter)

Selects the nodes filtered by filter, below the current node, but also returns the node in reference.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getDescendantOrSelfBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, below the current node, but also returns the node in reference.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getDescendantOrSelfByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, below the current node, but also returns the node in reference.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getElement(filter)

Selects the nodes filtered by filter, below the node in reference no matter the depth.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getElementBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, below the node in reference no matter the depth.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getElementByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, below the node in reference no matter the depth.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getElementByXpath(xpath)

Selects an element with an XPath selector xpath.

Arguments
  • xpath (string()) – XPath expression

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getFollowing(filter)

Selects the nodes filtered by filter, that are located on parent-level and also after (following) its parent of the node in reference.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getFollowingBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, that are located on parent-level and also after (following) its parent of the node in reference.

Arguments
  • svgTag (string()) –

  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getFollowingByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, that are located on parent-level and also after (following) its parent of the node in reference.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getFollowingSibling(filter)

Selects the nodes filtered by filter, that are located on the same level who are located after (following) the node in reference.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getFollowingSiblingBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, that are located on the same level who are located after (following) the node in reference.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getFollowingSiblingByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, that are located on the same level who are located after (following) the node in reference.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getParent()

Selects the parent of the current element.

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getPreceding(filter)

Selects the nodes filtered by filter, that are located on parent-level and also before (preceding) its parent of the node in reference.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getPrecedingBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, that are located on parent-level and also before (preceding) its parent of the node in reference.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getPrecedingByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, that are located on parent-level and also before (preceding) its parent of the node in reference.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getPrecedingSibling(filter)

Selects the nodes filtered by filter, that are located on the same level who are also located before (preceding) the node in reference.

Arguments
  • filter (IFilter()) – filter object

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getPrecedingSiblingBySVGTag(svgTag, filter)

Selects the SVG nodes with SVG tag svgTag filtered by filter, that are located on the same level who are also located before (preceding) the node in reference.

Arguments
  • svgTag (string()) – SVG tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.getPrecedingSiblingByTag(tag, filter)

Selects the nodes with tag tag filtered by filter, that are located on the same level who are also located before (preceding) the node in reference.

Arguments
  • tag (string()) – tag name

  • filter (IFilter()) –

Returns

XPathHelper – returns a new instance of XPathHelper

XPathHelper.toString()

Returns the corresponding Xpath query.

Returns

string – The corresponding XPath query

Filter: (filter)

ValidExpressionFilter

class ValidExpressionFilter(currentPath)

exported from filter

Implements:
  • IFilter()

XPath Filter containing a valid expression.

Creates an instance of ValidExpressionFilter.

Arguments
  • currentPath (string[]()) –

ValidExpressionFilter.sb

type: string[]

Array of string containing the different part of the filter expression.

ValidExpressionFilter.and(filters)

Adds one or more filter expression to the current one with the AND logical operator.

Arguments
  • filters (IFilter[]()) – List of filters that will be added with the AND logical operator

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression

ValidExpressionFilter.empty()

Empties the current path.

ValidExpressionFilter.isEmpty()

Returns true if filter is empty.

Returns

boolean – true if filter is empty.

ValidExpressionFilter.or(filters)

Adds one or more filter expression to the current one with the OR logical operator.

Arguments
  • filters (IFilter[]()) – List of filters that will be added with the OR logical operator

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression

ValidExpressionFilter.toString()

Returns the EmptyFilter as a valid XPath filter expression.

Returns

string – a valid XPath filter expression.

EmptyFilter

class EmptyFilter(currentPath)

exported from filter

Extends:
Implements:
  • IFilter()

Empty XPath filter.

Creates an instance of EmptyFilter.

Arguments
  • currentPath (string[]()) –

EmptyFilter.attributeContains(attribute, value)

Selects the nodes with the attribute attribute containing the value value.

Arguments
  • attribute (string()) –

  • value (string()) –

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.attributeEquals(attribute, value)

Selects the nodes with the attribute attribute, whose value equals value.

Arguments
  • attribute (string()) – attribute name

  • value (string|number()) – value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.attributeGreaterThan(attribute, value)

Selects the nodes with the attribute attribute, whose value is greater than value.

Arguments
  • attribute (string()) – attribute name

  • value (number()) – value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.attributeGreaterThanOrEqualTo(attribute, value)

Selects the nodes with the attribute attribute, whose value is greater than or equal to value.

Arguments
  • attribute (string()) – attribute name

  • value (number()) – value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.attributeLessThan(attribute, value)

Selects the nodes with the attribute attribute, whose value is less than value.

Arguments
  • attribute (string()) – attribute name

  • value (number()) – value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.attributeLessThanOrEqualTo(attribute, value)

Selects the nodes with the attribute attribute, whose value is less than or equal to value.

Arguments
  • attribute (string()) – attribute name

  • value (number()) – value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.attributeNotEquals(attribute, value)

Selects the nodes with the attribute attribute, whose value doesn’t equal value.

Arguments
  • attribute (string()) – attribute name

  • value (string|number()) – value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.get(index)

Selects the node element who is positioned at the index position in its parent children list.

Arguments
  • index (number()) – index value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.getFirst()

Selects the node element who is positioned first in its parent children list.

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.getLast()

Selects the node element who is positioned last in its parent children list.

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.hasAttribute(attribute)

Selects the nodes that have the attribute attribute.

Arguments
  • attribute (string()) – attribute name

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.not(filter)

Reverses the filter filter. Returns true when the filter returns false and true when the filter returns false.

Arguments
  • filter (IFilter()) – filter object

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.valueContains(value)

Selects the nodes containing the value value.

Arguments
  • value (string()) – node value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.valueEquals(value)

Selects the nodes whose value equals value.

Arguments
  • value (string|number()) – node value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.valueGreaterThan(value)

Selects the nodes whose value is greater than value.

Arguments
  • value (number()) – node value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.valueGreaterThanOrEqualTo(value)

Selects the nodes whose value is greater than or equal to value.

Arguments
  • value (number()) – node value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.valueLessThan(value)

Selects the nodes whose value is less than value.

Arguments
  • value (number()) – node value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.valueLessThanOrEqualTo(value)

Selects the nodes whose value is less than or equal to value.

Arguments
  • value (number()) – node value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.valueNotEquals(value)

Selects the nodes with whose value doesn’t equal value.

Arguments
  • value (string|number()) – node value

Returns

ValidExpressionFilter – a new instance of ValidExpressionFilter with the newly formed expression.

EmptyFilter.ANY_ATTRIBUTE

type: string

Shortcut to design any attribute name