I have seen many questions on here regarding saving data to xml and I have managed to create a form that does so (thanks guys who asked and answered), there is only one minor blip
Here is the code so you know what I mean
<?php
function insertxml($Iname,$Iurl)
{
$doc = new DOMDocument;
//$doc->preserveWhiteSpace = false;
$doc->load("bookmark.xml");
// we want a nice output
//$doc->formatOutput = true;
$root = $doc->getElementsByTagName('bookmark')->item(0);
$title = $doc->createElement('url', $Iurl);
$domAttribute = $doc->createAttribute('name');
$domAttribute->value = ('$Iname');
$title->appendChild($domAttribute);
$newtitle = $root->appendChild($title);
echo 'Wrote: ' . $doc->save("bookmark.xml") . ' bytes'; // Wrote: 72 bytes
}
$Name = $_POST['name'];
$Url = $_POST['url'];
insertxml($Name,$Url);
?>
and the form looks like so:
<!DOCTYPE html>
<html>
<head>
<title> Xml Reader</title>
</head>
<body>
<form action="index.php" method="post">
Name: <input type="text" name="name"><br>
URL: <input type="text" name="url"><br>
<input type="submit">
</form>
</body>
</html>
the code works fine however when I put 'Test' in the name box and 'http://test.com' in the url box it comes out like this:
<url name="$Iname">http://test.com</url>
What i would like is
<url name="test">http://test.com</url>
<url name="(what ever name I put in the name box)">(what ever name I put in the url box)</url>
ultimatly what syntax should i put for the following?:
$title = $doc->createElement('url', $Iurl);