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

        $fragment = $doc->createDocumentFragment();
        @$fragment->appendXML($xml);
        $node = @$doc->appendChild($fragment);

        return $node !== false;
    }
public static function isValidXmlFragment($xml, $doc = null)
    {
        if ($doc == null) {
            $doc = new DOMDocument("1.0", "ISO-8859-1");
        }

        $fragment = $doc->createDocumentFragment();
        @$fragment->appendXML($xml);
        $node = @$doc->appendChild($fragment);

        return $node !== false;
    }
public static function isValidXmlFragment ( $ xml , $ doc = null ) { if ( $ doc == null ) { $ doc = new DOMDocument ( "1.0" , "ISO-8859-1" ) ; } $ fragment = $ doc -> createDocumentFragment ( ) ; @ $ fragment -> appendXML ( $ xml ) ; $ node = @ $ doc -> appendChild ( $ fragment ) ; return $ node !== false ; }
Is a valid XML fragment?

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

@return boolean
Is a valid XML fragment?