Appending XML
Posted: Fri Nov 14, 2008 3:35 am
Silly question:
I have never worked with php and now am in a problem. working with flex i need to write a small php code which writes XML.
I am able to append the xml file with this quote
<?php
$test = "<row label='".$_REQUEST['firstname']." ".$_REQUEST['lastname']."'/>";
$open = fopen("contact.xml", 'a');
$write = fwrite($open, $test);
?>
But the problem is it appends the line at the end.
<?xml version='1.0' encoding='ISO-8859-1' ?>
<rows>
<row label='Ajay Jain'/>
</rows><row label='Ashish Jain'/>
I want to append the line before </rows> and in a different line. That means it should look like
<?xml version='1.0' encoding='ISO-8859-1' ?>
<rows>
<row label='Ajay Jain'/>
<row label='Ashish Jain'/>
</rows>
Can anyone help me in the codes...
I have never worked with php and now am in a problem. working with flex i need to write a small php code which writes XML.
I am able to append the xml file with this quote
<?php
$test = "<row label='".$_REQUEST['firstname']." ".$_REQUEST['lastname']."'/>";
$open = fopen("contact.xml", 'a');
$write = fwrite($open, $test);
?>
But the problem is it appends the line at the end.
<?xml version='1.0' encoding='ISO-8859-1' ?>
<rows>
<row label='Ajay Jain'/>
</rows><row label='Ashish Jain'/>
I want to append the line before </rows> and in a different line. That means it should look like
<?xml version='1.0' encoding='ISO-8859-1' ?>
<rows>
<row label='Ajay Jain'/>
<row label='Ashish Jain'/>
</rows>
Can anyone help me in the codes...