Convert an XML file into a SimpleXMLElement object, then output keys and elements of the object in PHP
Description
The following code shows how to convert an XML file into a SimpleXMLElement object, then output keys and elements of the object.
Example
//from ww w . ja v a 2s . c o m
<?php
$xml=simplexml_load_file("test.xml");
print_r($xml);
?>
The following code is for test.xml.
// ww w. ja v a 2 s . c o m
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Work</to>
<from>Home</from>
<heading>Reminder</heading>
<body>This is a message.</body>
</note>
The code above generates the following result.