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? Quote 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>"; ?> Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.