• PHP Video Tutorials

PHP - Function Simplexml Load File



Syntax

simplexml_load_file(file,classname,options,ns,is_prefix);

Definition and Usage

It used to converts simple xml file into a SimpleXMLElement object.

Return Values

It returns a SimpleXMLElement object on success or false on failure

Parameters

Sr.No Parameters & Description
1

file

It is used to specifies the path to the xml file

2

classname

It is used to specifies the class of new object

3

ns

It is used to specifies a namespace prefix or URI

4

is_prefix

It is used to specifies boolean value if result is true than ns is prefix or else gives a result as false

Example

Try out the following example

<?php
   $xml = simplexml_load_file("sample.xml");
   print_r($xml);
?>

This will produce following result −

SimpleXMLElement Object ( [to] => gopal [from] => CEO [heading] => Reminder [body] => Don't forget to send a file to me )
php_function_reference.htm
Advertisements