Class NodeVariable

java.lang.Object
scriptella.driver.xpath.NodeVariable

public class NodeVariable extends Object
A special node variable for sub-queries and scripts that wraps the node selected by an XPath query, exposing useful methods.
Author:
Martin Alderson
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NodeVariable(scriptella.driver.xpath.XPathExpressionCompiler compiler, Node node)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String expression)
    Gets the text value(s) of the node(s) selected by the specified XPath expression.
    getString(String expression)
    Gets the string value of the first selected node by the specified XPath expression.
    getString(String expression, String ifNull)
    Gets the string value of the first selected node by the specified XPath expression.
    getStringArray(String expression)
    Gets the text values of the nodes selected by the specified XPath expression.
    void
    Removes this node from the document.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • NodeVariable

      public NodeVariable(scriptella.driver.xpath.XPathExpressionCompiler compiler, Node node)
  • Method Details

    • getStringArray

      public String[] getStringArray(String expression)
      Gets the text values of the nodes selected by the specified XPath expression.
      Parameters:
      expression - xpath expression to evaluate.
      Returns:
      a String array of text values of the selected nodes.
    • getString

      public String getString(String expression)
      Gets the string value of the first selected node by the specified XPath expression.
      Parameters:
      expression - xpath expression to evaluate.
      Returns:
      the text value of the first selected node, or null.
    • getString

      public String getString(String expression, String ifNull)
      Gets the string value of the first selected node by the specified XPath expression.
      Parameters:
      expression - xpath expression to evaluate.
      ifNull - String to return if the specified expression evaluates to null.
      Returns:
      the text value of the first selected node, or the specified string if null.
    • get

      public Object get(String expression)
      Gets the text value(s) of the node(s) selected by the specified XPath expression.
      Parameters:
      expression - xpath expression to evaluate.
      Returns:
      a String array of the selected nodes, or just a single String if one node found.
    • remove

      public void remove()
      Removes this node from the document. This is especially useful to improve performance and reduce memory usage when processing large documents.