This is a partial of my xml file now
<entrys>
<customer>
<name> foo </name>
<city> bar </city>
</customer>
</entrys>
This is what I'll change it to...
<entrys>
<customer>
<name id="1"> foo </name>
<city id=”2”> bar </city>
</customer>
</entrys>
The variable I have reflects the first example...
<?php
if (isset($_POST['lsr-submit']))
{
header('Location: http://www.domain.net/test.php');
}
$str = '<?xml version="1.0" encoding="UTF-8"?><entrys></entrys>';
$xml = simplexml_load_string($str);
$fname = $_POST['firstname'];
$lname = $_POST['lastname'];
$location = $_POST['location'];
$report = $_POST['report'];
$description = $_POST['desc'];
$fname = htmlentities($fname, ENT_COMPAT, 'UTF-8', false);
$lname = htmlentities($lname, ENT_COMPAT, 'UTF-8', false);
$location = htmlentities($location, ENT_COMPAT, 'UTF-8', false);
$report = htmlentities($report, ENT_COMPAT, 'UTF-8', false);
$description = htmlentities($description, ENT_COMPAT, 'UTF-8', false);
$xml->reports = "";
$xml->reports->addChild('fname', $fname);
$xml->reports->addChild('lname', $lname);
$xml->reports->addChild('location', $location);
$xml->reports->addChild('report', $report);
$xml->reports->addChild('description', $description);
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$doc->preserveWhiteSpace = true;
$doc->loadXML($xml->asXML(), LIBXML_NOBLANKS);
$doc->save('test2.xml');
?>
here is part of my form...
<form name="lsrReports" action="xml/process.php" onSubmit="return defaultagree(this)" method="post" >
<table width="50%" align="center" cellpadding="2" cellspacing="0">
<tr>
<td> name:</td><td> <input type="text" name="name" value=<?php echo $xml->customer->name; ?> /></td>
</tr>
<tr>
<td> city:</td><td> <input type="text" name="city" value=<?php echo $xml->customer->city; ?> /></td>
</tr>
<tr>
<td> state:</td><td> <input type="text" name="state" value=<?php echo $xml->customer->state; ?> /></td>
</tr>
</form>
My question is how can I do this operation by id instead of name using what I've written so far? I hoping it's something simple :/