Returns the value of a given xpath element
@param string $xpath
@return string
@throws DriverException
428343
public function getValue($xpath) {
    $this->findElement($xpath, 1);
    $javascript = $this->javascriptTemplateRender("get_value.js.twig", array("xpath" => $xpath));
    return $this->browser->evaluate($javascript);
  }
973063
public function attachFile($xpath, $path) {
    if (!file_exists($path)) {
      throw new DriverException("Wow there the file does not exist, you can not upload it");
    }

    if (($realPath = realpath($path)) === false) {
      throw new DriverException("Wow there the file does not exist, you can not upload it");
    }

    $element = $this->findElement($xpath, 1);
    $tagName = $this->getTagName($xpath);
    if ($tagName != "input") {
      throw new DriverException("The element is not an input element, you can not attach a file to it");
    }

    $attributes = $this->getBrowser()->attributes($element["page_id"], $element["ids"][0]);
    if (!isset($attributes["type"]) || $attributes["type"] != "file") {
      throw new DriverException("The element is not an input file type element, you can not attach a file to it");
    }

    $this->browser->selectFile($element["page_id"], $element["ids"][0], $realPath);
  }
623008
public function xpath() {
    if (!isset($this->xpath)) {
      $this->xpath = new \DOMXPath($this);
    }

    return $this->xpath;
  }
46373
public function focus($xpath) {
    $element = $this->findElement($xpath, 1);
    $this->browser->trigger($element["page_id"], $element["ids"][0], "focus");
  }
110894
public static function GetRound( $value )
	{
		$xmlType = null;

		if ( $value instanceof XPath2Item )
		{
			$xmlType = $value->getSchemaType();
			$value = $value->getTypedValue();
		}

		if ( $value instanceof Undefined )
		{
			return $value;
		}

		if ( $value instanceof DecimalValue )
		{
			return $value->getRound( 0 );
		}

		if ( is_double( $value ) )
		{
			return XPath2Item::fromValueAndType( round( $value, 0, $value > 0 ? PHP_ROUND_HALF_UP : PHP_ROUND_HALF_DOWN ), is_null( $xmlType ) ? XmlSchema::$Double : $xmlType );
		}

		if ( $value instanceof Long )
		{
			return $value;
		}

		if ( Integer::IsDerivedSubtype( $value ) )
		{
			$value = Integer::ToInteger( $value );
		}

	    if ( $value instanceof Integer )
	    {
	    	return $value;
	    }
		else
			throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
				array(
					SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $value ), XmlTypeCardinality::One ),
					"xs:float | xs:double | xs:decimal | xs:integer in fn:round()"
				)
			);
	}
614301
protected function _getElement($sSelector)
    {
        if (strpos($sSelector, 'link=') === 0) {
            return $this->_getElementByLink($sSelector);
        }
        if (strpos($sSelector, 'css=') === 0) {
            return $this->_getElementByCss($sSelector);
        }
        if (strpos($sSelector, '/') === false) {
            return $this->_getElementByIdOrName($sSelector);
        }

        return $this->getMinkSession()->getPage()->find('xpath', $sSelector);
    }
268538
protected function getData($xpath)
    {
        $xpath = trim($xpath, '/');

        if (isset($this->data[$xpath])) {
            return $this->data[$xpath];
        }

        throw new EssenceException('Unregistered Element XPath: "/'.$xpath.'"');
    }
459023
public static XPath parse(String xpath) throws IllegalArgumentException {
        XPath xp = new XPath();

        // save the xpath as the full xpath
        xp.fullXPath = xpath;
        
        // does the xpath end with /*
        if (xpath.length() >= 2 && xpath.endsWith("/*")) {
            xp.includeChildren = true;
            xpath = xpath.substring(0, xpath.length()-2);
        }

        // normalized path is the rest
        xp.normalizedXPath = xpath;

        return xp;
    }
1114349
private function getOtherValue( $val )
	{
		/**
		 * @var XPath2Item $otherValue
		 */
		$otherValue = $val->getValue();
		return $otherValue instanceof XPath2Item
			? $otherValue->getValue()
			: $otherValue;
	}
1265672
private function getCssFromAllStyleNodes(\DOMXPath $xPath)
    {
        $styleNodes = $xPath->query('//style');

        if ($styleNodes === false) {
            return '';
        }

        $css = '';
        /** @var \DOMNode $styleNode */
        foreach ($styleNodes as $styleNode) {
            $css .= "\n\n" . $styleNode->nodeValue;
            $styleNode->parentNode->removeChild($styleNode);
        }

        return $css;
    }
79230
protected function Gt( $val )
	{
	    if ( $val->GetValueCode() != DateProxyFactory::Code )
	        throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
				array(
					"op:gt",
					SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $this->_value ), XmlTypeCardinality::One ),
					SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $val->getValue() ), XmlTypeCardinality::One )
				)
			);
	    return  $this->_value->CompareTo( $val->getValue() ) > 0;
	}
237242
private function getXPath(): \DOMXPath
    {
        $xpath = new \DOMXPath($this);
        $xpath->registerNamespace('xlf', self::XLIFF_NS);

        return $xpath;
    }
1188736
public function get($xpathExpression, $alwaysReturnArray = false)
    {
        if ($this->useCaching === true && $alwaysReturnArray === true) {
            if (!array_key_exists($xpathExpression, $this->cache['alwaysArray'])) {
                $this->cache['alwaysArray'][$xpathExpression] = $this->getFromDOMDocument($xpathExpression, $alwaysReturnArray);
            }

            return $this->cache['alwaysArray'][$xpathExpression];
        } elseif ($this->useCaching === true) {
            if (!array_key_exists($xpathExpression, $this->cache['optionalArray'])) {
                $this->cache['optionalArray'][$xpathExpression] = $this->getFromDOMDocument($xpathExpression, $alwaysReturnArray);
            }

            return $this->cache['optionalArray'][$xpathExpression];
        } else {
            return $this->getFromDOMDocument($xpathExpression, $alwaysReturnArray);
        }
    }
1166610
public function ToDouble( $provider )
	{
		try
		{
			if ( is_null( $this->_doubleValue ) )
			{
				$this->_doubleValue = Convert::ToDouble( $this->Value, $provider );
			}
			return is_null( $this->_doubleValue ) ? null : (double)$this->_doubleValue;
		}
		catch ( FormatException $ex )
		{
			throw XPath2Exception::withErrorCodeAndParams("FORG0001", Resources::FORG0001, array( $this->Value, "xs:double") );
		}
	}
554098
public static function parse($html, $xpath) {
		$doc = new \DOMDocument();
		$doc->loadHTML($html);
		$domxpath = new \DOMXPath($doc);
		$node = $domxpath->evaluate($xpath)->item(0);

		return new static($node);
	}
172368
public static function parseElementXml(SimpleXMLElement $xml){

        $attributes = array();
        foreach($xml->attributes() as $name => $value){
            $attributes[$name] = (string) $value;
        }

        $returnValue = array(
            'qtiClass' => $xml->getName()
        );

        if(count($attributes)){
            $returnValue['attributes'] = $attributes;
        }

        return $returnValue;
    }
1121819
protected function getXPath()
    {
        if (!$this->xpath) {
            $this->xpath = new \DOMXPath($this->getDomElement()->ownerDocument);
            $namespaces = $this->getExtensions()->getNamespaces();
            foreach ($namespaces as $prefix => $namespace) {
                $this->xpath->registerNamespace($prefix, $namespace);
            }
        }

        return $this->xpath;
    }