What is the reason for this outputted XML file
<?xml version="1.0"?>
<table>
<order>
<id/>
<name/>
<age/>
</order>
<order><id>1</id><name>baven</name><age>44</age></order><order><id>1</id><name>baven</name><age>44</age></order></table>
this is my database.xml page
my full code is:
<?php
$url='database.xml';
$xml = simplexml_load_file($url);
?>
<html>
<head>
<script type="text/javascript" src="jquery-latest.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
</script>
</head>
<body>
<div align="right">
<form action="parser1.php" method="POST">
<table border="0">
<tr>
<td>id </td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td>name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>age</td>
<td><input type="text" name="age"></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="submit"></td>
</tr>
</table>
</form>
</div>
<div style="cursor: pointer">
<table border='1' id='myTable' class='tablesorter' name='myTable'>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<?php
foreach($xml as $xmls) // loop through our books
{
?>
<tr>
<?php echo "<td>".$xmls->id."</td>";?>
<?php echo "<td>".$xmls->name."</td>";?>
<?php echo "<td>".$xmls->age."</td>";?>
</tr>
<?php
}
?>
</tbody>
<?php
$id =(isset($_POST['id']) ? strip_tags($_POST['id']) : '');
$name = (isset($_POST['name']) ? strip_tags($_POST['name']) : '');
$age =(isset($_POST['age']) ? strip_tags($_POST['age']) : '');
$doc= new DOMDocument();
$doc->formatOutput = true;
$doc->load("database.xml");
if ($doc->getElementsByTagName("table")->length == 0) {
$library = $doc->createElement("table");
$doc->appendChild($library);
$book = $doc->createElement("order");
$prop = $doc->createElement('id', $id);
$book->appendChild($prop);
$prop = $doc->createElement("name", $name);
$book->appendChild($prop);
$prop = $doc->createElement('age', $age);
$book->appendChild($prop);
$library->appendChild($book);
$doc->save('database.xml');
}
else {
$library = $doc->documentElement;
$book = $doc->createElement('order');
$prop = $doc->createElement('id', $id);
$book->appendChild($prop);
$prop = $doc->createElement('name', $name);
$book->appendChild($prop);
$prop = $doc->createElement('age', $age);
$book->appendChild($prop);
$library->appendChild($book);
$doc->save('database.xml');
}
?>
<!-- <thead>
<tr>
<th>id</th>
<th>name</th>
<th>age</th>
</tr>
</thead>-->
<!-- <tbody>
</tbody>-->
</table>
</div>
</body>
</html>
Any help would be appreciated...