src/dom/Dom.php
public static function isValidXml($xml, $doc = null)
    {
        if ($doc == null) {
            $doc = new DOMDocument("1.0", "ISO-8859-1");
        }

        // tries to load the document and gets the errors
        $useInternalErrors = libxml_use_internal_errors(true);
        $doc->loadXML($xml);
        $errors = libxml_get_errors();
        libxml_use_internal_errors($useInternalErrors);

        return count($errors) == 0;
    }
public static function isValidXml($xml, $doc = null)
    {
        if ($doc == null) {
            $doc = new DOMDocument("1.0", "ISO-8859-1");
        }

        // tries to load the document and gets the errors
        $useInternalErrors = libxml_use_internal_errors(true);
        $doc->loadXML($xml);
        $errors = libxml_get_errors();
        libxml_use_internal_errors($useInternalErrors);

        return count($errors) == 0;
    }
public static function isValidXml ( $ xml , $ doc = null ) { if ( $ doc == null ) { $ doc = new DOMDocument ( "1.0" , "ISO-8859-1" ) ; } // tries to load the document and gets the errors $ useInternalErrors = libxml_use_internal_errors ( true ) ; $ doc -> loadXML ( $ xml ) ; $ errors = libxml_get_errors ( ) ; libxml_use_internal_errors ( $ useInternalErrors ) ; return count ( $ errors ) == 0 ; }
Is a valid XML document?

@param string      $xml XML document
@param DOMDocument $doc Document (not required)

@return boolean
Is a valid XML document?