xPath

@access public
@return mixed
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');
    }
108391
public function getDOMDocument()
    {
        if ($this->domDocument instanceof DOMDocument === false) {
            $this->domDocument = new DOMDocument('1.0', 'UTF-8');

            libxml_clear_errors();
            $previousSetting = libxml_use_internal_errors(true);

            @$this->domDocument->loadXML($this->response->getBody());

            libxml_clear_errors();
            libxml_use_internal_errors($previousSetting);
        }

        return $this->domDocument;
    }
1320602
function nextNode() {
    if (empty($this->html)) {
      # we are done with parsing the html string
      return false;
    }
    static $skipWhitespace = true;
    if ($this->isStartTag && !$this->isEmptyTag) {
      array_push($this->openTags, $this->tagName);
      if (in_array($this->tagName, $this->preformattedTags)) {
        # dont truncate whitespaces for <code> or <pre> contents
        $this->keepWhitespace++;
      }
    }

    if ($this->html[0] == '<') {
      $token = substr($this->html, 0, 9);
      if (substr($token, 0, 2) == '<?') {
        # xml prolog or other pi's
        /** TODO **/
        #trigger_error('this might need some work', E_USER_NOTICE);
        $pos = strpos($this->html, '>');
        $this->setNode('pi', $pos + 1);
        return true;
      }
      if (substr($token, 0, 4) == '<!--') {
        # comment
        $pos = strpos($this->html, '-->');
        if ($pos === false) {
          # could not find a closing -->, use next gt instead
          # this is firefox' behaviour
          $pos = strpos($this->html, '>') + 1;
        } else {
          $pos += 3;
        }
        $this->setNode('comment', $pos);

        $skipWhitespace = true;
        return true;
      }
      if ($token == '<!DOCTYPE') {
        # doctype
        $this->setNode('doctype', strpos($this->html, '>')+1);

        $skipWhitespace = true;
        return true;
      }
      if ($token == '<![CDATA[') {
        # cdata, use text node

        # remove leading <![CDATA[
        $this->html = substr($this->html, 9);

        $this->setNode('text', strpos($this->html, ']]>')+3);

        # remove trailing ]]> and trim
        $this->node = substr($this->node, 0, -3);
        $this->handleWhitespaces();

        $skipWhitespace = true;
        return true;
      }
      if ($this->parseTag()) {
        # seems to be a tag
        # handle whitespaces
        if ($this->isBlockElement) {
          $skipWhitespace = true;
        } else {
          $skipWhitespace = false;
        }
        return true;
      }
    }
    if ($this->keepWhitespace) {
      $skipWhitespace = false;
    }
    # when we get here it seems to be a text node
    $pos = strpos($this->html, '<');
    if ($pos === false) {
      $pos = strlen($this->html);
    }
    $this->setNode('text', $pos);
    $this->handleWhitespaces();
    if ($skipWhitespace && $this->node == ' ') {
      return $this->nextNode();
    }
    $skipWhitespace = false;
    return true;
  }
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;
    }
638739
public function xpath($path)
    {
        $xpath = new \DOMXPath($this->dom);

        $list = $xpath->query($path);

        $return = [];
        foreach ($list as $node) {
            $return[] = $this->newElement($node);
        }

        return $return;
    }
1046310
public function seeXmlResponseMatchesXpath($xpath)
    {
        $structure = new XmlStructure($this->connectionModule->_getResponseContent());
        $this->assertTrue($structure->matchesXpath($xpath), 'xpath not matched');
    }
1289633
protected function getXML()
    {
        $key = 'xml_' . md5($this->url); // Everybody loves md5!

        if ($this->cache->has($key)) {
            $this->xml = $this->cache->get($key);
        } else {
            $this->xml = $this->fetchXML();

            $this->xml = $this->changeLinkElements($this->xml);

            $this->cache->put($key, $this->xml, $this->cacheTime);
        }
    }
1106532
public function getElements()
    {
        foreach ($this->elements as $name => $element) {
            $this->resolveXRef($name);
        }

        return $this->elements;
    }
341820
public function xpath($path) {
    $results = parent::xpath($path);
    if (empty($results)) {
      return $this->_getEmptyElement();
    }
    return new QuipXmlElementIterator(new \ArrayIterator($results));
  }
237242
private function getXPath(): \DOMXPath
    {
        $xpath = new \DOMXPath($this);
        $xpath->registerNamespace('xlf', self::XLIFF_NS);

        return $xpath;
    }
79968
protected function getXPath()
    {
        $xpath = new \DOMXPath($this->doc);

        $xpath->registerNamespace('xliff', self::NS);

        return $xpath;
    }
874853
public function extractLinks()
    {
        if ($this->extractedLinks) {
            return $this->extractedLinks;
        }

        if (!is_html($this->body)) {
            return [];
        }

        $libxmlPreviousState = libxml_use_internal_errors(true);

        $dom = new DOMDocument;
        $dom->loadHTML($this->body);

        libxml_clear_errors();
        libxml_use_internal_errors($libxmlPreviousState);

        $links = [];

        foreach ($this->tags as $tag => $attribute) {
            foreach ($dom->getElementsByTagName($tag) as $element) {
                $link = $element->getAttribute($attribute);

                if (!$link) {
                    continue;
                }

                $links[] = clean_url(url_to_absolute($this->url, $link), true, true);
            }
        }

        return $this->extractedLinks = array_unique($links);
    }
1264531
public function getXml()
    {
		$res  = '<widgetcontainer widgetAlias="'.htmlspecialchars($this->widgetAlias).'" widgetTitle="'.htmlspecialchars($this->widgetTitle).'" widgetDisabled="'.(int)$this->widgetDisabled.'" widgetProtected="'.(int)$this->widgetProtected.'">'."\n\n";
		foreach ($this->getChildren() as $w) {
			$res .= $w->getXml()."\n";
		}
		$res .= '</widgetcontainer>'."\n";
		return $res;
	}
794163
public function xpath($path) {
    if ($path{0} === '/') {
      $this->rewind();
      if ($this->valid()) {
        return $this->current()->xpath($path);
      }
      return $this->_getEmptyElement();
    }

    return $this->_eachGetIterator('xpath', $path);
  }
26699
public function getAll($name)
	{
		$xpathStr = '';
		if (is_string($name)) {
			$xpathStr = self::XPATH_ROOT . $name;
		}
		else if (is_array($name)) {
			$xpathStr = self::XPATH_ROOT . implode(' | ' . self::XPATH_ROOT, $name);
		}
		$results = $this->xpath($xpathStr);
		return $results;
	}
1112385
public function parse( $xml )
	{
		$this->loadXml( $xml );
		$root	= $this->document->firstChild;
		while( $root->nodeType == XML_COMMENT_NODE )
			$root	= $root->nextSibling;

		$tree	= new XML_DOM_Node( $root->nodeName );
		if( $root->hasAttributes())
		{
			$attributeNodes	= $root->attributes;
			foreach( $attributeNodes as $attributeNode )
				$tree->setAttribute( $attributeNode->nodeName, $attributeNode->nodeValue );
		}
		$this->parseRecursive( $root, $tree );
		return $tree;
	}
821356
public function getEmisor()
    {
        if (!$this->xml) {
            return false;
        }
        $RE = $this->xml->getElementsByTagName('RE')->item(0);
        return $RE ? $RE->nodeValue : false;
    }