• PHP Video Tutorials

PHP - Function Simplexml Import Dom



Syntax

simplexml_import_dom(node,classname);

Definition and Usage

Returns a SimpleXMLElement object from a DOM node

Return Values

It returns a SimpleXMLElement object on success or false on failure

Parameters

Sr.No Parameters & Description
1

node

It is used to specifies dom element node

2

classname

It is used to specifies the class of new object

Example

Try out the following example

<?php
   $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;
?>

This will produce following result −

Title2
php_function_reference.htm
Advertisements