Code:
clg.xml
<?xml version="1.0" encoding="UTF-8"?>
<college>
<dep>
<id>001</id>
<name>B.Voc</name>
</dep>
<dep>
<id>002</id>
<name>CS</name>
</dep>
<dep>
<id>003</id>
<name>Physics</name>
</dep>
</college>
<college>
<dep>
<id>001</id>
<name>B.Voc</name>
</dep>
<dep>
<id>002</id>
<name>CS</name>
</dep>
<dep>
<id>003</id>
<name>Physics</name>
</dep>
</college>
index.php
<!DOCTYPE html>
<html>
<body>
<center>
<h1>Content of XML file to Drop-Down</h1>
<?php
$abc=simplexml_load_file('clg.xml');
echo "<select name='dep'>";
foreach ($abc->Children() as $d)
{
echo "<option value='".$d->id."'>".$d->name."</option>";
}
echo "</select>";
?>
</center>
</body>
</html>
<html>
<body>
<center>
<h1>Content of XML file to Drop-Down</h1>
<?php
$abc=simplexml_load_file('clg.xml');
echo "<select name='dep'>";
foreach ($abc->Children() as $d)
{
echo "<option value='".$d->id."'>".$d->name."</option>";
}
echo "</select>";
?>
</center>
</body>
</html>
No comments:
Post a Comment