We will write the following codes and save it as file name 'example.xml'.
<producer>
<producer>
<name>Thet</name>
<age>30</age>
</producer>
<producer>
<name>Jan</name>
<age>21</age>
</producer>
<producer>
<name>Feb</name>
<age>23</age>
</producer>
<producer>
<name>Mar</name>
<age>25</age>
</producer>
</producer>
And then we will write the following codes and save it as file name 'xml.php'.
<?php
$xml = simplexml_load_file('example.xml');
foreach($xml -> producer as $producer){
echo $producer -> name.' is '.$producer ->age.'.</br>';
}
?>
If you will type 'xml.php' in your brwoser, you will see all data in xml file.
No comments:
Post a Comment