org.apache.jmeter.extractor

## Class XPath2Extractor

- java.lang.Object
- - org.apache.jmeter.testelement.AbstractTestElement
  - - org.apache.jmeter.testelement.AbstractScopedTestElement
    - - org.apache.jmeter.extractor.XPath2Extractor

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Searchable, PostProcessor, TestElement

      public class XPath2Extractor
      extends AbstractScopedTestElement
      implements PostProcessor, java.io.Serializable

  Extracts text from (X)HTML response using XPath query language Example XPath queries:
  /html/head/title
    extracts Title from HTML response
  //form[@name='countryForm']//select[@name='country']/option[text()='Czech Republic'])/@value
    extracts value attribute of option element that match text 'Czech Republic' inside of select element with name attribute 'country' inside of form with name attribute 'countryForm'
  //head
    extracts the XML fragment for head node.
  //head/text()
    extracts the text content for head node.
  see org.apache.jmeter.extractor.TestXPathExtractor for unit tests
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_VALUE_AS_STRING`

    - ### Fields inherited from interface org.apache.jmeter.testelement.TestElement

      `COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XPath2Extractor()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getDefaultValue()`
    `boolean` | `getFragment()` Should we return fragment as text, rather than text of fragment?
    `int` | `getMatchNumber()` Return which Match to use.
    `java.lang.String` | `getMatchNumberAsString()` Return which Match to use.
    `java.lang.String` | `getNamespaces()`
    `java.lang.String` | `getRefName()`
    `java.lang.String` | `getXPathQuery()`
    `void` | `process()` Do the job - extract value from (X)HTML response using XPath Query.
    `void` | `setDefaultValue(java.lang.String val)`
    `void` | `setFragment(boolean selected)` Should we return fragment as text, rather than text of fragment?
    `void` | `setMatchNumber(int matchNumber)` Set which Match to use.
    `void` | `setMatchNumber(java.lang.String matchNumber)` Set which Match to use.
    `void` | `setNamespaces(java.lang.String namespaces)`
    `void` | `setRefName(java.lang.String refName)`
    `void` | `setXPathQuery(java.lang.String val)`

    - ### Methods inherited from class org.apache.jmeter.testelement.AbstractScopedTestElement

      `fetchScope, getSampleList, getScopeName, getVariableName, isScopeAll, isScopeChildren, isScopeParent, isScopeVariable, isScopeVariable, setScopeAll, setScopeChildren, setScopeParent, setScopeVariable`

    - ### Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

      `addPropertiesValues, addProperty, addProperty, addTestElement, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.jmeter.testelement.TestElement

      `removed`

- - ### Field Detail

    - #### DEFAULT_VALUE_AS_STRING

          public static final java.lang.String DEFAULT_VALUE_AS_STRING

  - ### Constructor Detail

    - #### XPath2Extractor

          public XPath2Extractor()

  - ### Method Detail

    - #### process

          public void process()

      Do the job - extract value from (X)HTML response using XPath Query. Return value as variable defined by REFNAME. Returns DEFAULT value if not found.
      Specified by:
        `process` in interface `PostProcessor`

    - #### setXPathQuery

          public void setXPathQuery(java.lang.String val)

    - #### getXPathQuery

          public java.lang.String getXPathQuery()

    - #### setRefName

          public void setRefName(java.lang.String refName)

    - #### getRefName

          public java.lang.String getRefName()

    - #### setDefaultValue

          public void setDefaultValue(java.lang.String val)

    - #### getDefaultValue

          public java.lang.String getDefaultValue()

    - #### getFragment

          public boolean getFragment()

      Should we return fragment as text, rather than text of fragment?
      Returns:
        true if we should return fragment rather than text

    - #### setFragment

          public void setFragment(boolean selected)

      Should we return fragment as text, rather than text of fragment?
      Parameters:
        `selected` - true to return fragment.

    - #### setMatchNumber

          public void setMatchNumber(int matchNumber)

      Set which Match to use. This can be any positive number, indicating the exact match to use, or `0`, which is interpreted as meaning random.
      Parameters:
        `matchNumber` - The number of the match to be used

    - #### setMatchNumber

          public void setMatchNumber(java.lang.String matchNumber)

      Set which Match to use. This can be any positive number, indicating the exact match to use, or `0`, which is interpreted as meaning random.
      Parameters:
        `matchNumber` - The number of the match to be used

    - #### getMatchNumber

          public int getMatchNumber()

      Return which Match to use. This can be any positive number, indicating the exact match to use, or `0`, which is interpreted as meaning random.
      Returns:
        matchNumber The number of the match to be used

    - #### getMatchNumberAsString

          public java.lang.String getMatchNumberAsString()

      Return which Match to use. This can be any positive number, indicating the exact match to use, or `0`, which is interpreted as meaning random.
      Returns:
        matchNumber The number of the match to be used

    - #### setNamespaces

          public void setNamespaces(java.lang.String namespaces)

    - #### getNamespaces

          public java.lang.String getNamespaces()

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.