I’m trying to update an XML file through some input fields. Users will put info into the inupt fields, hit ‘submit,’ and then their information will be loaded into the XML file. To achieve this, I’m using PHP. The PHP file i’m modifying to achieve this is the same one used in the XML Guestbook tutorial found on this site. The PHP updates the XML file perfectly; no problems there.
However, when the PHP writes the XML, everything is put into one really long string. This is where my problem lies. I need a new line between the opening tag of the XML file (<?xml version=“1.0”?>) and the rest of the file. I need this new line so my XML file can be read by another .swf (for some reason, this .swf wont read the XML unless the rest of the XML data is on a different line than the first tag). So basically, i want the PHP to load to input data into the XML nodes, yet insert a new line after the <?xml version=“1.0”?> tag.
My PHP file follows:
<?php
$xmlString = $HTTP_RAW_POST_DATA;
if (is_null($xmlString)) {
print “No data was sent”;
}
else {
$file = fopen(“cal.xml”, “w+”) or die(“Can’t open XML file”);
if(!fwrite($file, $xmlString)){
print “Error writing to XML-file”;
}
print $xmlString."
";
fclose($file);
}
?>
Here’s my XML file before being updated by the PHP:
<?xml version=“1.0”?>
[color=gray]Here’s where i need the space, all the rest of the file can be on one line[/color]
<Calendar>
[color=gray]here’s where the new xml info from my input fields will go[/color]
</Calendar>
Any ideas? All i need is a new line to be put in before the new inputs are put in. I’d appreciate any help. Thanks.