How to create a xml file.
create_xml.php

<html>
<head>
<title>PHP XML Functions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#C0C0C0" text="#000080">
<form method="POST" action="php_xml.php">
<input type="hidden" name="posted" value="true">
<table width="517" border="0" cellpadding="10">
<tr><td width="502"><h2><font size="3">Create HTML files on the fly</font></h2>
<?php
if (isset($_POST['posted'])) {
$cmdButton = $_POST['cmdButton'];
$root_element_name = $_POST['root_element_name'];
$element01_name = $_POST['element01_name'];
$att0101_name = $_POST['att0101_name'];
$att0101_value = $_POST['att0101_value'];
$att0102_name = $_POST['att0102_name'];
$att0102_value = $_POST['att0102_value'];
$element0101_name = $_POST['element0101_name'];
$att010101_name = $_POST['att010101_name'];
$att010101_value = $_POST['att010101_value'];
$att010102_name = $_POST['att010102_name'];
$att010102_value = $_POST['att010102_value'];
switch ($cmdButton) {
case "Create XML Document";
//format an xml document
$xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$doc_type_dec = "";
$root_element_start = "<" . $root_element_name . ">";
$root_element_end = "</" . $root_element_name . ">";
$xml_doc = $xml_dec;
$xml_doc .= $doc_type_dec;
$xml_doc .= $root_element_start;
$xml_doc .= "<" . $element01_name . " "
. $att0101_name . "=" . "'" . $att0101_value . "'" . " "
. $att0102_name . "=" . "'" . $att0102_value . "'" . ">";
$xml_doc .= "<" . $element0101_name . " "
. $att010101_name . "=" . "'" . $att010101_value . "'" . " "
. $att010102_name . "=" . "'". $att010102_value . "'" . ">";
$xml_doc .= "</" . $element0101_name . ">";
$xml_doc .= "</" . $element01_name . ">";
$xml_doc .= $root_element_end;
//open a file and copy the xml text into it, then close it
$default_dir = "C:\\Apache2\\htdocs\\php5\\tutorials_example\\xml_related";
$fp = fopen($default_dir . "\\" . $_POST['xml_file_name'] . ".xml", 'w');
$write = fwrite($fp, $xml_doc);
$response_message = "XML document created";
break;
default;
break;
}
}
?>
<table width="343" border="1"><tr>
<td width="496"><font face="Arial, Helvetica, sans-serif" size="-1"><b>Create
a Well-formed XML Document</b></font></td>
</tr><tr><td width="496">
<table width="492" border="1" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"><tr>
<td colspan="3" width="480"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Response =
<?php echo $response_message; ?></font></b></font></td>
</tr><tr>
<td width="101"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Element or Attribute</font></b></font></td>
<td width="148"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Name</font></b></font></td>
<td width="221"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Value</font></b></font></td>
</tr><tr>
<td width="101"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Root Element:</font></b></font></td>
<td width="148">
<input type="text" name="root_element_name" size="20">
</td><td width="221">&nbsp;</td></tr><tr>
<td width="101"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">
<font color="#008000">Element1</font>:</font></b></font></td>
<td width="148">
<input type="text" name="element01_name" size="20">
</td><td width="221">&nbsp;</td></tr><tr>
<td width="101"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Attribute1:</font></b></font></td>
<td width="148">
<input type="text" name="att0101_name" size="20">
</td><td width="221">
<input type="text" name="att0101_value" size="20">
</td></tr><tr>
<td width="101"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Attribute2:</font></b></font></td>
<td width="148">
<input type="text" name="att0102_name" size="20">
</td><td width="221">
<input type="text" name="att0102_value" size="20">
</td></tr><tr><td width="101">
<font size="-1"><b><font face="Arial, Helvetica, sans-serif">
<font color="#008000">Element2</font>:
</font></b></font></td>
<td width="148">
<input type="text" name="element0101_name" size="20">
</td><td width="221">&nbsp;</td></tr><tr>
<td width="101"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Attribute1:</font></b></font></td>
<td width="148">
<input type="text" name="att010101_name" size="20">
</td><td width="221">
<input type="text" name="att010101_value" size="20">
</td></tr><tr>
<td width="101"><font size="-1"><b><font face="Arial, Helvetica, sans-serif">Attribute2:</font></b></font></td>
<td width="148">
<input type="text" name="att010102_name" size="20">
</td><td width="221">
<input type="text" name="att010102_value" size="20">
</td></tr><tr>
<td width="101">Name XML document</td>
<td width="369" colspan="2">
<p align="center">
<input type="text" name="xml_file_name" size="30"><br>
do not add file extension, it will write xml extension</td></tr><tr>
<td width="101">&nbsp;</td>
<td width="148">
<input type="submit" value="Create XML" name="B1" style="float: right"></td>
<td width="221">
<a href="create_xml.php"><font color="#000080">
Reload</font> </a>
</td></tr><tr>
<td width="101">&nbsp;</td>
<td colspan="2" width="375" align="center">
<p align="left">
<b><font face="Arial, Helvetica, sans-serif">
Directory contents</font></b><br/>
<?php
$default_dir = "C:\\Apache2\\htdocs\\php5\\tutorials_example\\xml_related";
//C:\Apache2\htdocs\php5\tutorials_example\xml_related
if (!($dp = opendir($default_dir))) {
die("Cannot open $default_dir.");
}
while ($file = readdir($dp)) {
if ($file != '.' && $file != '..') {
echo "<a href=$file>$file </a><br/>";
}
}
closedir($dp);
?>
</p>
<p>&nbsp;</td></tr></table></td></tr> </table>
</td></tr></table>
</form>
</body>
</html>

fill out the form appropriate