s_ainley87 Posted July 10, 2008 Share Posted July 10, 2008 Hi There! I currently have an XML file that looks like this..... <menuBase> <country> England </country> <country> France </country> <country> Germany </country> </menuBase> how would I loop through that file and get the results i.e England, France, Germany into a Drop Down Form Menu? Link to comment https://forums.phpfreaks.com/topic/114060-loop-through-xml-with-php/ Share on other sites More sharing options...
rhodesa Posted July 10, 2008 Share Posted July 10, 2008 SimpleXML is the way to go. <?php $file = 'filename.xml'; $sxml = simplexml_load_file($file); echo "<select name=\"country\">"; foreach($sxml->country as $country) echo "<option value=\"{$country}\">{$country}</option>"; echo "</select>"; ?> Link to comment https://forums.phpfreaks.com/topic/114060-loop-through-xml-with-php/#findComment-586268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.