Wednesday, 23 August 2017

XML

<?xml version="1.0"?> 

<userlist> --> Array Name

<user>  -----> Object Name

<name>Bimal Roy </name> ---> Tag Name
<mobile> 9876543210 ---> value </mobile>
<city> Bangalore </city>
<pincode> 560037</pincode>

</user>

<user>
<name> Robi Thakur </name>
<mobile> 9988776655 </mobile>
<city> Pune </city>
<pincode> 560032</pincode>

</user>

<user>
<name> Subhas Bose </name>
<mobile> 8877665544 </mobile>
<city> Delhi </city>
<pincode> 560030</pincode>

</user>

</userlist>


==================================================================
<?php
$xml = simplexml_load_file("one.xml"); // to read a xml file

?>

<table align="center" border=2>
<tr>
<th> Full Name </th>
<th> Mobile No. </th>
<th> City </th>
<th>Pincode </th>

</tr>

<?php

for($i =0; $i<count($xml); $i++){
echo "<tr>";

echo "<td>". $xml->user[$i]->name . "</td>";
echo "<td>". $xml->user[$i]->mobile . "</td>";
echo "<td>". $xml->user[$i]->city . "</td>";
echo "<td>". $xml->user[$i]->pincode . "</td>";

echo "</tr>";
}

?>
</table>
******************************************************************************

No comments:

Post a Comment

Download

https://drive.google.com/open?id=0BwJUPBOmHUUoLXA3TWdFQnRIeXc https://drive.google.com/file/d/1DMlCY1tycw-USBbs9kuxUtqo64fXRwU3/view?usp=...