/** * * @return XMLDom */ public static function loadXMLString($s) { $x = new static(); libxml_use_internal_errors(true); // @codingStandardsIgnoreStart if (!@$x->loadXML($s)) { // @codingStandardsIgnoreEnd $errors = libxml_get_errors(); libxml_clear_errors(); libxml_use_internal_errors(false); throw new \DOMException("Errore caricamento stringa '" . (strlen($s) > 30 ? substr($s, 0, 27) : $s) . "'\n" . self::libxml2string($errors)); } libxml_use_internal_errors(false); return $x; }
/** * @param $xml * @return XML */ public static function createByXml($xml) { $instance = new static('1.0', 'utf-8'); $instance->loadXML($xml, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG); return $instance; }