I need to append an XML document with the PHP programming language?

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Guest
In short I have a seperate XML document with the information as follows:
<?xml version="1.0"?>
<pages>

<links>
<title>Cool things</title>
<url>http://www.coolthings.com</url>
</links>

<links>
<title>Cool things</title>
<url>http://www.coolthings.com</url>
</links>

/*Here I want to add another <links> <url> <title> </links> set with php using the following php form*/
</pages>

<?php
$url = $_POST["url"];
$title = $_POST["title"];

if (!isset($url))
{
echo

"<html>
<head>
</head>
<body>


<form action=\"updatexml.php\" method=\"post\">
<table>
<tr><td>
<span>URL</span></td><td><input type=\"text\" name=\"url\" />
</td></tr>

<tr><td>
<span>TITLE</span></td><td><input type=\"text\" name=\"title\" />
</td></tr>
<input type=\"submit\" value=\"submit XML\">

</form>

<body>
</html>";

die();
}
else{
/* PHP code that will append the xml document with $url and $title within the <pages> parent*/



echo "<B>Data Appended<B>";


}
?>

How do I go about making this happen I have tried several things already, and I have made the code append the <url> and <title> nodes into the pages node, butI want the <links> node to be a parent to them, and a child to <pages>

Any help would be much appreciated
 
Back
Top