Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP simplexml_import_dom() Function

PHP simplexml_import_dom() Function

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual

Example

Get a DOM document node and convert it to a SimpleXML node:

loadXML(" ToveJani "); $x=simplexml_import_dom($dom); echo $x->from; ?>

Run Example »


Definition and Usage

The simplexml_import_dom() function returns a SimpleXMLElement object from a DOM node.


Syntax

simplexml_import_dom(

node,classname

);

Parameters Description
node Required. Specifies the DOM element node.
classname Optional. Specifies the class of the new object.

Technical Details

Return Value: Returns a SimpleXMLElement object on success, or FALSE on failure.
PHP Version: 5+

More examples

Example 1

Output the title of the second book node in the DOM document:

loadXML(" Title1 Title2 "); $x=simplexml_import_dom($dom); echo $x->book[1]->title; ?>

Run Example »


PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual