Hi,
I have two php scripts: 1st to read the xml file and another to write modified data.
Here is the code of the first one:
<?
$xml = simplexml_load_file("test.xml");
foreach($xml->children() as $child)
{
echo "<form name=Edit2 action=parser.php method=post><td><tr></tr><tr><td width=78><textarea rows=5 cols=30 name=" . $child->getName() . ">" . $child . "</textarea></td><td width=78><input type=submit value=Submit ></td></tr></form>";
}
?>
=So all of child are the separate forms and that was my plan, and it is not a problem.
But when I go further and start coding the second one - I have the problem.
I wanted to do exacly same structure of code with the "foreach" construct, but it is not working at all.
<?php
$xml = simplexml_load_file("test.xml");
foreach($xml->children() as $child)
if (!empty($_POST[$child->getName()])) {
$var = $_POST[$child->getName()];
$var = $child;// THIS IS MY PROBLEMATIC LINE!
foreach($xml->children() as $child)//testing if script made changes
{
echo $child->getName() . ": " . $child . "<br />";
}
}
?>
As you can see I wanted to have '$child->getName()' as the posted name from the form . But it isn't working.
I'm not thinking good in this second script for sure..