Wrap the xpath results in a Quip iterator.
@see SimpleXMLElement::xpath()
@return \QuipXml\Xml\QuipXmlElementIterator
341820
public function xpath($path) {
    $results = parent::xpath($path);
    if (empty($results)) {
      return $this->_getEmptyElement();
    }
    return new QuipXmlElementIterator(new \ArrayIterator($results));
  }
221728
public function loadAsXSLTProcessor()
    {
        $this->checkFileExists();
        $xsl = new \XSLTProcessor();
        $xsl->importStylesheet($this->loadAsXML());
        return $xsl;
    }
1084773
public function xpath($expression, $wrapNode = true)
    {
        return $this->find($expression, Query::TYPE_XPATH, $wrapNode);
    }
572907
public function xml()
    {
        foreach ($this->_result as $ps) {
            $xmlps = $this->xml->addChild("Process");
            $xmlps->addAttribute("Name", $ps[0]);
            $xmlps->addAttribute("Status", $ps[1] ? 1 : 0);
        }

        return $this->xml->getSimpleXmlElement();
    }
187487
public function getLabel()
    {
        $xpath = new \DOMXPath($this->node->ownerDocument);

        if ($this->node->hasAttribute('id')) {
            $labels = $xpath->query(sprintf('descendant::label[@for="%s"]', $this->node->getAttribute('id')));
            if ($labels->length > 0) {
                return $labels->item(0);
            }
        }

        $labels = $xpath->query('ancestor::label[1]', $this->node);
        if ($labels->length > 0) {
            return $labels->item(0);
        }
    }
892869
public function getValue()
	{
		// return $this->_value;

		switch ( $this->_xmlType->TypeCode )
		{
			case XmlTypeCode::String:

				return $this->_value;

			case XmlTypeCode::Double:

				if ( is_infinite( $this->_value ) )
				{
					return $this->_value > 0 ? INF : -INF;
				}

				return $this->_value;

			case XmlTypeCode::Float:

				if ( is_infinite( $this->_value ) )
				{
					return $this->_value > 0 ? INF : -INF;
				}

				return $this->_value;

		}

		return XPath2Convert::ToString( $this->_value );
	}
725167
protected function getArrayFromXml(SimpleXmlIterator $iterator)
    {
        $result = [];

        for($iterator->rewind(); $iterator->valid(); $iterator->next())
        {
            if($iterator->hasChildren())
            {
                foreach($iterator->getChildren() as $key => $value)
                {
                    if(1 <= $value->count())
                    {
                        $result[$iterator->key()][][$key] = $this->getArrayFromXml($value);
                    }
                    else
                    {
                        if(true === $value->hasChildren())
                        {
                            $result[$iterator->key()][$key] = $this->getArrayFromXml($value);
                        }
                        else
                        {
                            $result[$iterator->key()] = $this->getArrayFromXml($iterator->current());
                        }
                    }
                }
            }
            else
            {
                $result[$iterator->key()] = $this->convertToStringOrBoolean($iterator->current());
            }
        }

        return $result;
    }
151596
public function asXML()
    {
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><item></item>',
            LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_ERR_FATAL);
        $xml->addChild('title', $this->title);
        $xml->addChild('link', $this->url);
        if ($this->pubDate !== null) {
            $xml->addChild('pubDate', date(DATE_RSS, $this->pubDate));
        }

        if ($this->creator) {
            $xml->addChildCData("xmlns:dc:creator", $this->creator);
        }
        if ($this->guid) {
            $guid = $xml->addChild('guid', $this->guid);

            if ($this->isPermalink === false) {
                $guid->addAttribute('isPermaLink', 'false');
            }
        }

        foreach ($this->categories as $category) {
            $element = $xml->addChild('category', $category[0]);

            if (isset($category[1])) {
                $element->addAttribute('domain', $category[1]);
            }
        }

        $xml->addChild('description', $this->description);
        if(strlen(trim($this->content)) > 0) {
            $xml->addChildCData('xmlns:content:encoded', $this->content);
        }

        if (is_array($this->enclosure) && (count($this->enclosure) == 3)) {
            $element = $xml->addChild('enclosure');
            $element->addAttribute('url', $this->enclosure['url']);
            $element->addAttribute('type', $this->enclosure['type']);

            if ($this->enclosure['length']) {
                $element->addAttribute('length', $this->enclosure['length']);
            }
        }

        return $xml;
    }
784566
public function toXML(){

            $oXMLout = new \XMLWriter();
            $oXMLout->openMemory();
            $oXMLout->setIndent(true);
            $oXMLout->setIndentString('    ');


        $oXMLout->startDocument("1.0", 'utf-8');
        $oXMLout->startElement('tasks');

        /**
         * @var \Dlin\Saasu\Task\Task $task
         */
        foreach($this->tasks as $task){
           $oXMLout->writeRaw("\n".$task->toXML());
        }
        $oXMLout->endElement();
        $oXMLout->endDocument();

        $xml = $oXMLout->outputMemory();

        return $xml;
    }
592711
protected function get_parser() {
        $parser = xml_parser_create();
        xml_set_object($parser, $this);
        xml_set_element_handler($parser, 'tag_open', 'tag_close');
        xml_set_character_data_handler($parser, 'cdata');
        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
        return $parser;
    }
1356333
public function getHtml()
    {
        $code = $this->code;

        if (empty($code)) {
            return;
        }

        $errors = libxml_use_internal_errors(true);
        $entities = libxml_disable_entity_loader(true);

        $dom = new \DOMDocument();
        $dom->loadHTML($code);

        libxml_use_internal_errors($errors);
        libxml_disable_entity_loader($entities);

        return Utils::xpathQuery($dom, 'descendant-or-self::body/*', false);
    }
878882
public function asXML()
    {
        $p = new XMLElement('p', $this->message, array('role' => 'alert'));
        $p->setAttribute('class', 'notice');

        if ($this->type !== self::NOTICE) {
            $p->setAttribute('class', 'notice ' . $this->type);
        }

        return $p;
    }
26346
public function toXML()
    {
        $namespace = 'tns';
        $writer = new XMLWriter();
        $writer->openMemory();
        $writer->setIndent(true);
        $writer->setIndentString('    ');
        $writer->startElementNs($namespace, 'Naknada', null);
        $writer->writeElementNs($namespace, 'NazivN', null, $this->getName());
        $writer->writeElementNs($namespace, 'IznosN', null, $this->getValue());
        $writer->endElement();

        return $writer->outputMemory();
    }
173757
public function parse() {
		if($this->bParsed) {
			return;
		}

		if ($this->replacements) {
            // We cannot rely of html_entity_decode,
            // because it would replace &amp; and &lt; as well,
            // whereas we need to keep them unmodified.
            // We must do it manually, with a modified hardcopy
            // of PHP 5.4+ 's get_html_translation_table(ENT_XHTML)
            $this->source = XMLEntityTransformer::replace($this->source);
		}
		
		$this->xmlParser = xml_parser_create('UTF-8');
		xml_parser_set_option($this->xmlParser, XML_OPTION_CASE_FOLDING, false);
		xml_set_object($this->xmlParser, $this);
		xml_set_element_handler($this->xmlParser, 'openTagHandler', 'closeTagHandler');
		xml_set_character_data_handler($this->xmlParser,'cdataHandler');

		//Prepare the detection of the very first tag, in order to compute
		//the offset in XML string as regarded by the parser.
		$this->firstOpening = true;

		try {
            $bSuccess = xml_parse($this->xmlParser, $this->source);
        } catch (RequiredAttributeException $ex) {
		    throw $ex->setFile($this->filename);
        }

        if ($bSuccess) {
            $errMsg = '';
            $lineNumber = 0;
        } else {
			$errMsg = xml_error_string(xml_get_error_code($this->xmlParser));
			$lineNumber = xml_get_current_line_number($this->xmlParser);
			if(count($this->stack)) {
				$lastElement = $this->stack[count($this->stack) - 1];
				if($lastElement instanceof ViewElementTag) {
					$errMsg .= '. Last element: ' . $lastElement->getTagName() . '(' . $lineNumber . ')';
				}
			}
		}

		xml_parser_free($this->xmlParser);
		$this->bParsed = $bSuccess;

		if(! $bSuccess ) {
			throw new XMLParsingException(
					$errMsg,
					$lineNumber);
		}

		// Store a serialized version of the parsed tree, if successfully parsed,
        // and if we've got a cache path.
        if ( ($this->cachePath) && ($this->filename !== null) && (! $this->unserialized) ) {
            $cacheFile = $this->makeCacheFilename($this->cachePath, $this->templatesRoot, $this->filename, true);
            file_put_contents($cacheFile, serialize($this));
        }


    }
202125
public function parseXML($xml)
    {
        $document = new \DOMDocument();

        $previousValue = libxml_use_internal_errors(true);
        libxml_clear_errors();
        $result = $document->loadXML($xml);
        /** @var \libXMLError[] $errors */
        $errors = libxml_get_errors();
        libxml_clear_errors();
        libxml_use_internal_errors($previousValue);

        if (true !== $result) {
            $message = [];
            foreach ($errors as $error) {
                $message[] = sprintf(
                    '%d. [%s] %s in on line %d in position %d',
                    count($message) + 1,
                    $error->code,
                    str_replace(["\n", "\r"], '', $error->message),
                    $error->line,
                    $error->column
                );
            }
            throw new RuntimeException('Can not parse XML: ' . implode('; ', $message));
        }

        return $this->parseDocument($document);
    }
128593
public function serializeToXml()
    {
        $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RefererConfiguration></RefererConfiguration>');
        if ($this->allowEmptyReferer) {
            $xml->addChild('AllowEmptyReferer', 'true');
        } else {
            $xml->addChild('AllowEmptyReferer', 'false');
        }
        $refererList = $xml->addChild('RefererList');
        foreach ($this->refererList as $referer) {
            $refererList->addChild('Referer', $referer);
        }
        return $xml->asXML();
    }
903412
public function getXPath()
    {
      if(!isset($this->xpath))
      {
        $this->xpath = new DOMXPath($this);

        if($this->documentElement->namespaceURI <> '')
          $this->xpath->registerNamespace('default', $this->documentElement->namespaceURI);

        /*foreach ($this->getNamespaces() as $prefix => $namespaceUri)
          $this->xpath->registerNamespace($prefix, $namespaceUri);*/
      }

      return $this->xpath;
    }