# Creating a dropdown menu using data from xml and using php

**URL:** <https://forum.kirupa.com/t/creating-a-dropdown-menu-using-data-from-xml-and-using-php/281670>\
**Category:** programming\
**Created:** [February 12, 2009, 12:56am UTC](https://forum.kirupa.com/t/creating-a-dropdown-menu-using-data-from-xml-and-using-php/281670 "2009-02-12T00:56:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flash\_Man1](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Flash\_Man1](https://forum.kirupa.com/u/Flash_Man1)\
**Post date:** [February 12, 2009, 12:56am UTC](https://forum.kirupa.com/t/creating-a-dropdown-menu-using-data-from-xml-and-using-php/281670/1 "2009-02-12T00:56:09Z")

</div>

Hi All,

Quick question:  
I have an xml file which lists the suburbs and the value number for each suburb.  
I wish to use this information from the XML file to populate my dropdown menu.

I am using php and here is what i have so far.

```php
<?php 

$file = "http://www.myxmlfile_xml.cgi?clientid=abcdef&searchtype=lease";

function contents($parser, $data){ 
    echo $data; 
} 

function startTag($parser, $data){ 
    echo "<b>"; 
} 

function endTag($parser, $data){ 
    echo "</b><br />"; 
} 

$xml_parser = xml_parser_create(); 

xml_set_element_handler($xml_parser, "startTag", "endTag"); 

xml_set_character_data_handler($xml_parser, "contents"); 

$fp = fopen($file, "r"); 

$data = fread($fp, 80000); 

if(!(xml_parse($xml_parser, $data, feof($fp)))){ 
    die("Error on line " . xml_get_current_line_number($xml_parser)); 
} 

xml_parser_free($xml_parser); 

fclose($fp); 

echo $data;

?>

```

Where do I go from here??

Thanks in advance
