English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP simplexml_import_dom() Function Usage and Example

PHP SimpleXML Function Manual

The simplexml_import_dom() function is used to obtain a SimpleXMLElement object from a DOM node.

Syntax

simplexml_import_dom(node, classname);

Definition and Usage

Returns a SimpleXMLElement object from the DOM node

Return Value

Returns a SimpleXMLElement object on success, false on failure

Parameter

NumberParameters and Description
1

node

Specify the DOM element node

2

classname

Specify the class of the new object

Online Example

Try the following example to get the DOM document node and convert it to a SimpleXML node:

<?php
   //Get the DOM document node and convert it to a SimpleXML node
   $dom = new domDocument;
   $dom->loadXML("<car><local><title
      Title1</title></local><local><title>
      Title2</title></local></car>");
   $x = simplexml_import_dom($dom);
   
   echo $x->local[1]->title;
?>
Test and See‹/›

Output Result

Title2

PHP SimpleXML Function Manual