# PHO to XML issues

**URL:** <https://forum.kirupa.com/t/pho-to-xml-issues/322655>\
**Category:** programming\
**Created:** [May 28, 2011, 11:39pm UTC](https://forum.kirupa.com/t/pho-to-xml-issues/322655 "2011-05-28T23:39:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazz2000](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mazz2000](https://forum.kirupa.com/u/mazz2000)\
**Post date:** [May 28, 2011, 11:39pm UTC](https://forum.kirupa.com/t/pho-to-xml-issues/322655/1 "2011-05-28T23:39:04Z")

</div>

Hi all,  
I’m just getting into XML.  
I’ve just completed a tutorial that i found on here with some success but i have a question.

I’ve written a page called xml.php for my test

This page on the server connects to my database and pulls out an id and a mobile handset name and model, the script i found on here then creates the xml.

When i view xml.php on the server i see all my id’s and handset names and if i view source i see the full xml structure.

All good!

but, this file is still a php file?

how would i then make this so it’s got the .xml extention?

this may be a very silly question because as i say i’m new to XML

here is my code

```php
<?php
require "dbcommon.php";
$result = mysql_query ("SELECT * FROM handsets");

$xml_output = "<?xml version=\"1.0\"?>
"; 
$xml_output .= "<entries>
"; 

for($x = 0 ; $x < mysql_num_rows($result) ; $x++){ 
    $row = mysql_fetch_assoc($result); 
    $xml_output .= "	<entry>
"; 
    $xml_output .= " <id>" . $row['product_id'] . "</id>
"; 
        // Escaping illegal characters 
        $h1 = str_replace("&", "&", $row['product_name/handset']); 
    $xml_output .= " <handset>" . $h1 . "</handset>
"; 
    $xml_output .= "	</entry>
"; 
} 

$xml_output .= "</entries>"; 

echo $xml_output;

?>

```

the source shows

```auto
<?xml version="1.0"?>
<entries>
	<entry>
		<id>105</id>
		<handset>BlackBerry RIM 7230</handset>
	</entry>
	<entry>
		<id>109</id>
		<handset>HP iPAQ h6300</handset>
	</entry>
	<entry>
		<id>111</id>
		<handset>HP iPAQ hw6510c</handset>
	</entry>
	<entry>
		<id>117</id>
		<handset>Motorola E1000</handset>
	</entry>
	<entry>
		<id>122</id>
		<handset>Motorola V1050</handset>
	</entry>
	<entry>

```

how would i then create this as say handsets.xml?

thank you
