DOMDocument::loadXML
(PHP 5, PHP 7, PHP 8)
DOMDocument::loadXML — Load XML from a string
Beschreibung
Loads an XML document from a string.
Parameter-Liste
-
source -
The string containing the XML.
-
options -
Bitwise
ORof the libxml option constants.
Rückgabewerte
Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben. If called statically, returns a
DOMDocumentBei einem Fehler wird false zurückgegeben..
Fehler/Exceptions
If an empty string is passed as the source,
a warning will be generated. This warning is not generated by libxml
and cannot be handled using libxml's error handling functions.
Vor PHP 8.0.0
konnte diese Methode statisch aufgerufen werden, gab dabei aber einen Fehler der Stufe E_DEPRECATED aus.
Seit PHP 8.0.0 löst der statische Aufruf dieser Methode eine Error-Exception aus.
Beispiele
Beispiel #1 Creating a Document
<?php
$doc = new DOMDocument();
$doc->loadXML('<root><node/></root>');
echo $doc->saveXML();
?>
Beispiel #2 Static invocation of loadXML
<?php
// Issues an E_DEPRECATED error
$doc = DOMDocument::loadXML('<root><node/></root>');
echo $doc->saveXML();
?>
Siehe auch
- DOMDocument::load() - Load XML from a file
- DOMDocument::save() - Dumps the internal XML tree back into a file
- DOMDocument::saveXML() - Dumps the internal XML tree back into a string

