Parse the entity XML.

@param   Callable[]       $callbacks Hooks for pre- and postprocessing of elements
@param   LocatorInterface $locator   The XML description file locator

@return  Element
6438
public function parse($callbacks, LocatorInterface $locator)
    {
        $data = null;

        while ($this->read()) {
            if ($this->nodeType == \XMLReader::ELEMENT) {
                $child = $this->parseElement($this->name, $callbacks, $locator);
                $data  = $child;
                break;
            }
        }

        return $data;
    }
735193
protected function __parseXmlToUpdateObject($xml)
  {
    $dom = new DOMDocument();

    // Attempt to prevent XXE that could be exploited through loadXML()
    libxml_disable_entity_loader(true);

    if (empty($xml) || !$dom->loadXML($xml, LIBXML_NOBLANKS)) return null;

    $rootNode = $dom->documentElement;

    if ($rootNode->nodeName == $this->getNodeName()) {
      // update the current object
      Recurly_Resource::__parseXmlToObject($rootNode->firstChild, $this, $this->_client);
    } else if ($rootNode->nodeName == 'errors') {
      // add element to existing object
      Recurly_Resource::__parseXmlToObject($rootNode->firstChild, $this->_errors, $this->_client);
    }
    $this->updateErrorAttributes();
  }
646931
private function parseCustomElementMarkup(CustomInteraction $customElement){
        
        $xincludes = array();
        $xml = new DOMDocument();
        $xml->formatOutput = true;
        $loadSuccess = $xml->loadXML($customElement->getMarkup());
        $node = $xml->documentElement;
        
        if($loadSuccess && !is_null($node)){
            $parser = new ParserFactory($xml);
            $xincludesNodes = $parser->queryXPath(".//*[name(.)='include']");
            foreach($xincludesNodes as $xincludeNode){
                $href = $xincludeNode->getAttribute('href');
                $asset = $this->resolver->resolve($href);
                $filePath = $asset->getMediaSource()->download($asset->getMediaIdentifier());
                if(file_exists($filePath)){
                    $fileContent = file_get_contents($filePath);
                    $xmlInclude = new DOMDocument();
                    $xmlInclude->formatOutput = true;
                    $xmlInclude->loadXML($fileContent);
                    foreach($xmlInclude->documentElement->childNodes as $node){
                        $importNode = $xml->importNode($node, true);
                        $xincludeNode->parentNode->insertBefore($importNode, $xincludeNode);
                    }
                }else{
                    throw new XIncludeException('The file referenced by href does not exist : '.$href, $xincludeNode);
                }
                $xincludeNode->parentNode->removeChild($xincludeNode);
                $xincludes[] = $href;
            }
        }else{
            throw new ParsingException('cannot parse pci markup');
        }

        $customElement->setMarkup($xml->saveXML(null, LIBXML_NOEMPTYTAG));
        
        return $xincludes;
    }
80244
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $content = $parsingDispatcher->parse($data['Content'], 'Content');

        return new Values\Content\Location(
            array(
                'contentInfo' => $content instanceof APIContent ? $content->getVersionInfo()->getContentInfo() : null,
                'id' => $data['_href'],
                'priority' => (int)$data['priority'],
                'hidden' => $data['hidden'] === 'true',
                'invisible' => $data['invisible'] === 'true',
                'remoteId' => $data['remoteId'],
                'parentLocationId' => $data['ParentLocation']['_href'],
                'pathString' => $data['pathString'],
                'depth' => (int)$data['depth'],
                'sortField' => $this->parserTools->parseDefaultSortField($data['sortField']),
                'sortOrder' => $this->parserTools->parseDefaultSortOrder($data['sortOrder']),
            )
        );
    }
1110213
public function selectorToXpath($selector, $locator)
    {
        if ('xpath' === $selector) {
            if (!is_string($locator)) {
                throw new \InvalidArgumentException('The xpath selector expects to get a string as locator');
            }

            return $locator;
        }

        return $this->getSelector($selector)->translateToXPath($locator);
    }
1227041
public function typeKeys($locator, $value)
    {
        try {
            return $this->getMinkSession()->getDriver()->getBrowser()->typeKeys($locator, $value);
        } catch (\Selenium\Exception $e) {
            sleep(1);
            return $this->getMinkSession()->getDriver()->getBrowser()->typeKeys($locator, $value);
        }
    }
26499
public function translateToXPath($locator)
    {
        if (!is_string($locator)) {
            throw new \InvalidArgumentException('The CssSelector expects to get a string as locator');
        }

        // Symfony 2.8+ API
        if (class_exists('Symfony\Component\CssSelector\CssSelectorConverter')) {
            $converter = new CssSelectorConverter();

            return $converter->toXPath($locator);
        }

        // old static API for Symfony 2.7 and older
        return CSS::toXPath($locator);
    }
844903
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        if (!array_key_exists('Role', $data)) {
            throw new Exceptions\Parser("Missing 'Role' element for RoleAssignInput.");
        }

        if (!is_array($data['Role']) || !array_key_exists('_href', $data['Role'])) {
            throw new Exceptions\Parser("Invalid 'Role' element for RoleAssignInput.");
        }

        try {
            $roleId = $this->requestParser->parseHref($data['Role']['_href'], 'roleId');
        } catch (Exceptions\InvalidArgumentException $e) {
            throw new Exceptions\Parser('Invalid format for <Role> reference in <RoleAssignInput>.');
        }

        // @todo XSD says that limitation is mandatory, but roles can be assigned without limitations
        $limitation = null;
        if (array_key_exists('limitation', $data) && is_array($data['limitation'])) {
            if (!array_key_exists('_identifier', $data['limitation'])) {
                throw new Exceptions\Parser("Missing '_identifier' attribute for Limitation.");
            }

            $limitation = $parsingDispatcher->parse(
                $data['limitation'],
                'application/vnd.ez.api.internal.limitation.' . $data['limitation']['_identifier']
            );
        }

        return new RoleAssignment($roleId, $limitation);
    }
26693
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
    {
        $locationUpdateStruct = $this->locationService->newLocationUpdateStruct();

        if (array_key_exists('priority', $data)) {
            $locationUpdateStruct->priority = (int)$data['priority'];
        }

        if (array_key_exists('remoteId', $data)) {
            $locationUpdateStruct->remoteId = $data['remoteId'];
        }

        $hidden = null;
        if (array_key_exists('hidden', $data)) {
            $hidden = $this->parserTools->parseBooleanValue($data['hidden']);
        }

        if (!array_key_exists('sortField', $data)) {
            throw new Exceptions\Parser("Missing 'sortField' element for LocationUpdate.");
        }

        $locationUpdateStruct->sortField = $this->parserTools->parseDefaultSortField($data['sortField']);

        if (!array_key_exists('sortOrder', $data)) {
            throw new Exceptions\Parser("Missing 'sortOrder' element for LocationUpdate.");
        }

        $locationUpdateStruct->sortOrder = $this->parserTools->parseDefaultSortOrder($data['sortOrder']);

        return new RestLocationUpdateStruct($locationUpdateStruct, $hidden);
    }
937584
public function extract(callable $callback = null)
    {

        if ($callback === null) {
            $result = $this->result->serialize();
        }
        else {
            $result = $callback($this->result->serialize());
        }

        return $result;

    }
817808
public function findAll($selector, $locator)
	{
		$items = array();

		foreach ( $this->_nodes as $node ) {
			$items = array_merge($items, $node->findAll($selector, $locator));
		}

		return $items;
	}
208265
public function parseDocument($xmlDocument)
    {
        $reader = new \XMLReader();
        $reader->open('data:text/plain;base64,' . base64_encode($xmlDocument));

        if ($this->skipRootNode) {
            $reader->read();
        }

        $this->stdClassObj = self::readerLoop($reader);
    }
277875
public function extract(callable $callback = null)
    {

        if ($callback === null) {
            $result = $this->result->toArray();
        }
        else {
            $result = $callback($this->result->toArray());
        }

        return $result;

    }
322538
public function checkField($locator)
    {
        $field = $this->findField($locator);

        if (null === $field) {
            throw new ElementNotFoundException($this->getDriver(), 'form field', 'id|name|label|value', $locator);
        }

        $field->check();
    }
735876
public function fillField($locator, $value)
    {
        $field = $this->findField($locator);

        if (null === $field) {
            throw new ElementNotFoundException($this->getDriver(), 'form field', 'id|name|label|value|placeholder', $locator);
        }

        $field->setValue($value);
    }
318762
public function getLocator($locator)
    {
        $locatorId = Utilities::getEntityId(
            $locator,
            'WindowsAzure\MediaServices\Models\Locator'
        );

        return Locator::createFromOptions(
            $this->_getEntity("Locators('{$locatorId}')")
        );
    }
1345438
public function findByXpath($locator)
    {
        $locator = \Normalizer::normalize($locator, \Normalizer::FORM_D);
        return parent::find($locator);
    }