<?Php
$obj_xml = new SimpleXMLElement('file-xml-demo.xml', NULL, TRUE);
// Total number of elements present ///
//$total = $obj_xml->count(); // total number of elements for PHP 5.3 and above
$total =count($obj_xml->children()); // for < php 5.3 version
$str="<select name='student'>";
for($i=0; $i<$total; $i++) {
$str= $str . "<option value=".$obj_xml->details[$i]->id.">".$obj_xml->details[$i]->name. "</option>";
}
$str = $str. "</select>";
echo $str;
?>
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.
| Schalk | 09-11-2018 |
| Ahhhhh, Yes. Thank you.This was exactly what I have been searching for. Thank you soooo much! | |