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);
    }
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);
    }
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 ) ; }
Parse XML and return Atom Document.

@param string $xml

@return Document

@throws \InvalidArgumentException If given document is not supported.
@throws \Mekras\Atom\Exception\RuntimeException In case of XML errors.

@since 1.0
Parse XML and return Atom Document .