What I am trying to do is to parse an xml file and create a drop-down for the user.
I have attached how my drop down list looks currently.
What I want to do is to add a sub list to each option.. say to networkSecurity I want to add option a,b,c,d which I have to read from the same xml file.
How this can be done ?
To create normal drop-down list my code looks like
Code: Select all
<?php
$xml=simplexml_load_file('info.xml');
foreach($xml->testcase as $var){
$var=explode('/',$var->script);
$module[] =$var[2];
$testName[] = end($var);
}
echo "<pre>";
print_r($module);
print_r($testName);
$modules = array_unique($module);
foreach($modules as $newarr)
{
$newmodules[]=$newarr;
}
print_r($newmodules);
?>
<select name="module" id="Module">
<?php
$i=0;
foreach($newmodules as $mod)
{
?>
<option value="<?php echo $mod;?>"><?php echo $newmodules[$i];?></option>
<?php
$i++;
}
?>
</select>