dom_import_simplexml
Description
The dom_import_simplexml of DOM for PHP gets a DOMElement.
Syntax
dom_import_simplexml(
object $node
): DOMElementParameters
node
The SimpleXMLElement node.
Return
Returns the DOMElement node.
Examples
1 · node
<?
$data =
<<<XML
<?xml version="1.0"?>
<people>
<person xmlns:a="https://osbo.com">
<a:first a:class="myclass" a:id="myid" a:title="mytitle">first</a:first>
<a:last>last</a:last>
<a:age>age</a:age>
</person>
<person xmlns:b="https://osbo.com">
<b:first b:class="myclass" b:id="myid" b:title="mytitle">first</b:first>
<b:last>last</b:last>
<b:age>age</b:age>
</person>
<person xmlns:c="https://osbo.com">
<c:first c:class="myclass" c:id="myid" c:title="mytitle">first</c:first>
<c:last>last</c:last>
<c:age>age</c:age>
</person>
</people>
XML;
$node = simplexml_load_string($data);
$return = dom_import_simplexml($node);
print_r($return);
DOMElement Object
(
[tagName] => people
[className] =>
[id] =>
[schemaTypeInfo] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 3
[previousElementSibling] =>
[nextElementSibling] =>
[nodeName] => people
[nodeValue] =>
first
last
age
first
last
age
first
last
age
[nodeType] => 1
[parentNode] => (object value omitted)
[parentElement] =>
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] =>
[attributes] => (object value omitted)
[isConnected] => 1
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => people
[baseURI] =>
[textContent] =>
first
last
age
first
last
age
first
last
age
)