simplexml_import_dom
simplexml_import_dom
Get a SimpleXMLElement object from an XML or HTML node
**simplexml_import_dom** object $node $class_name
This function takes a node of a document and makes it into a SimpleXML node. This new object can then be used as a native SimpleXML element. DOM
node
A Element node
DOM
class_name
You may use this optional parameter so that
will return an object of
the specified class. That class should extend the
class.
simplexml_import_dom``SimpleXMLElement
Returns a or null on failure.
SimpleXMLElement
Throws a when passed a
non-XML or non-HTML .
TypeError``node
**Voorbeeld: Importing a **
<?php
$dom = new DOMDocument;
$dom->loadXML('<books><book><title>blah</title></book></books>');
if (!$dom) {
echo 'Error while parsing the document';
exit;
}
$s = simplexml_import_dom($dom);
echo $s->book[0]->title;
?>
blah
**Voorbeeld: Importing a **
<?php
$dom = Dom\XMLDocument::createFromString('<books><book><title>blah</title></book></books>');
$s = simplexml_import_dom($dom);
echo $s->book[0]->title;
?>
blah
dom_import_simplexml