VOOZH about

URL: https://www.geeksforgeeks.org/php/php-simplexml_import_dom-function/

⇱ PHP | simplexml_import_dom() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP | simplexml_import_dom() Function

Last Updated : 29 Mar, 2023

The simplexml_import_dom() function is an inbuilt function in PHP which is used to take a node of DOM document and convert it into a SimpleXML node. 

Syntax:

SimpleXMLElement simplexml_import_dom( $node, $class_name = "SimpleXMLElement" )

Parameters: This function accepts two parameters as mentioned above and described below:

  • $node: This parameter holds the DOM element node.
  • $class_name: It is optional parameter which holds the class name. If this parameter is used then simplexml_import_dom() function returns the object of specified class. The class should extend the SimpleXMLElement class.

Return Value: This function returns the SimpleXMLElement on success or FALSE on failure. 

Below program illustrates the simplexml_import_dom() function in PHP: 

Program:

Output:
object(SimpleXMLElement)#3 (1) {
 [0]=>
 string(21) "abc@geeksforgeeks.org"
}
object(SimpleXMLElement)#3 (1) {
 [0]=>
 string(13) "+91-987654321"
}

Reference: https://www.php.net/manual/en/function.simplexml-import-dom.php

Comment