Returns the inner html of a given xpath
@param string $xpath
@return string
@throws DriverException
778482
public function getHtml($xpath) {
    $elements = $this->findElement($xpath, 1);
    //allText works only with ONE element so it will be the first one
    return $this->browser->allHtml($elements["page_id"], $elements["ids"][0], "inner");
  }
826532
private function filterRelativeXPath($xpath)
    {
        $prefixes = $this->findNamespacePrefixes($xpath);

        $crawler = $this->createSubCrawler(null);

        foreach ($this->nodes as $node) {
            $domxpath = $this->createDOMXPath($node->ownerDocument, $prefixes);
            $crawler->add($domxpath->query($xpath, $node));
        }

        return $crawler;
    }
712843
private function GetReference($ID, $xPath) {	
		$query = '//*[@Id="'.$ID.'"]';
		$nodeset = $xPath->query($query);
		$Object = $nodeset->item(0);
		
		return $Object;
	}
1311761
public function isSelected($xpath) {
    $elements = $this->findElement($xpath, 1);
    $javascript = $this->javascriptTemplateRender("is_selected.js.twig", array("xpath" => $xpath));
    $tagName = $this->browser->tagName($elements["page_id"], $elements["ids"][0]);
    if (strcmp(strtolower($tagName), "option") !== 0) {
      throw new DriverException("Can not assert on element that is not an option");
    }

    return $this->browser->evaluate($javascript);
  }
1148764
public function findXPath(string $xpath): NodeList {
        $results = $this->newNodeList();

        if ($this->isRemoved()) {
            return $results;
        }

        $domxpath = new \DOMXPath($this->document());

        foreach ($this->collection() as $node) {
            $results = $results->merge(
                $node->newNodeList($domxpath->query($xpath, $node))
            );
        }

        return $results;
    }
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;
    }
1334815
protected function getHtmlDescription($html)
    {
        $content = '';
        $doc = new \DOMDocument;
        @$doc->loadHTML($html);
        $xpath = new \DOMXPath($doc);

        $query = '//p[preceding-sibling::p]';

        foreach ($xpath->query($query) as $node) {
            $content .= trim($node->textContent, PHP_EOL);
        }

        return $content;
    }
1261532
public function submitForm($xpath) {
    $element = $this->findElement($xpath, 1);
    $tagName = $this->browser->tagName($element["page_id"], $element["ids"][0]);
    if (strcmp(strtolower($tagName), "form") !== 0) {
      throw new DriverException("Can not submit something that is not a form");
    }
    $this->browser->trigger($element["page_id"], $element["ids"][0], "submit");
  }
355037
public function toText($html)
    {
        $parser = new Parser();

        $xmlParser = xml_parser_create();
        xml_set_element_handler($xmlParser, [$parser, 'startElement'], [$parser, 'endElement']);
        xml_set_character_data_handler($xmlParser, [$parser, 'characterData']);

        $wrappedHtml = "<root>$html</root>";
        $returnStatus = xml_parse($xmlParser, $wrappedHtml, true);

        if (!$returnStatus) {
            return $html;
        }

        return $parser->getText();
    }
428514
public function xpath($query)
    {
        if ($this->ownerDocument) {
            return $this->ownerDocument->getXpath()->query($query, $this);
        }

        throw new BadMethodCallException('cannot xpath on element without an owner document');
    }
1309024
function get_inner_html( DOMElement $element ) {

        $inner_html= '';

        $children = $element->childNodes;

        foreach ( $children as $child ) {

            $inner_html .= $child->ownerDocument->saveXML( $child );

        }

        return $inner_html;

    }
676794
private function splitUnionParts($xpath)
    {
        if (false === strpos($xpath, '|')) {
            return array($xpath); // If there is no pipe in the string, we know for sure that there is no union
        }

        $xpathLen = strlen($xpath);
        $openedBrackets = 0;
        // Consume whitespaces chars at the beginning of the string (this is the list of chars removed by trim() by default)
        $startPosition = strspn($xpath, " \t\n\r\0\x0B");

        $unionParts = array();

        for ($i = $startPosition; $i <= $xpathLen; ++$i) {
            // Consume all chars until we reach a quote, a bracket or a pipe
            $i += strcspn($xpath, '"\'[]|', $i);

            if ($i < $xpathLen) {
                switch ($xpath[$i]) {
                    case '"':
                    case "'":
                        // Move to the end of the string literal
                        if (false === $i = strpos($xpath, $xpath[$i], $i + 1)) {
                            return array($xpath); // The XPath expression is invalid, don't split it
                        }
                        continue 2;
                    case '[':
                        ++$openedBrackets;
                        continue 2;
                    case ']':
                        --$openedBrackets;
                        continue 2;
                }
            }
            if ($openedBrackets) {
                continue;
            }

            $unionParts[] = substr($xpath, $startPosition, $i - $startPosition);

            if ($i === $xpathLen) {
                return $unionParts;
            }

            // Consume any whitespace chars after the pipe
            $i += strspn($xpath, " \t\n\r\0\x0B", $i + 1);
            $startPosition = $i + 1;
        }

        return array($xpath); // The XPath expression is invalid
    }
208160
public static function getXmlContent($filePath)
    {
        $useErrors = libxml_use_internal_errors(true);
        $content = simplexml_load_file($filePath);
        if (false === $content) {
            $error = libxml_get_last_error();
            throw new \Exception(sprintf("%s in %s", $error->message, $error->file));
        }

        libxml_clear_errors();
        libxml_use_internal_errors($useErrors);

        return $content;
    }
316843
static function xpathQuery($html, $xpath) {
		$ddoc = new \DOMDocument();
		@$ddoc->loadHTML($html);
	
		$dxpath = new \DOMXPath($ddoc);
		return $dxpath->query($xpath);
	}
1227428
public function dontSeeXmlResponseMatchesXpath($xpath)
    {
        $structure = new XmlStructure($this->connectionModule->_getResponseContent());
        $this->assertFalse($structure->matchesXpath($xpath), 'accidentally matched xpath');
    }
1053951
public function xpathOne($path)
    {
        $result = $this->xpath($path);
        if(is_array($result))
            return current($result);

        return $result;

    }
543028
public function _getValue($xpath)
    {
        $xpathEscaped = json_encode($xpath);
        $script = <<<JS
var node = this.browserbot.locateElementByXPath({$xpathEscaped}, window.document),
tagName = node.tagName.toLowerCase(),
value = null;
if (tagName == 'input' || tagName == 'textarea') {
var type = node.getAttribute('type');
if (type == 'checkbox') {
value = node.checked;
} else if (type == 'radio') {
var name = node.getAttribute('name');
if (name) {
var fields = window.document.getElementsByName(name),
i, l = fields.length;
for (i = 0; i < l; i++) {
var field = fields.item(i);
if (field.checked) {
value = field.value;
break;
}
}
}
} else {
value = node.value;
}
} else if (tagName == 'select') {
if (node.getAttribute('multiple')) {
value = [];
for (var i = 0; i < node.options.length; i++) {
if (node.options[i].selected) {
value.push(node.options[i].value);
}
}
} else {
var idx = node.selectedIndex;
if (idx >= 0) {
value = node.options.item(idx).value;
} else {
value = null;
}
}
} else {
value = node.getAttribute('value');
}
JSON.stringify(value)
JS;
        $sResult = json_decode($this->getMinkSession()->getDriver()->getBrowser()->getEval($script));

        return preg_replace("/[ \n]+/", " ", $sResult);
    }