I've manage to do just that, however I need the text to be wrapped in CDATA tags as it'll later be used in a Flash website. Also the original xml file has CDATA tags but when php writes back to the node it loses the CDATA bit.
I'm really confused about it all, I'm just php beginner, I've spent 8 hours googling it trying to learn about what's going on, but I'm still clueless - even more so now...
So here's what I've got:
An XML file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<site>
<aboutpage>
<copya><![CDATA[This is the about page text.]]></copya>
</aboutpage>
</site>
Code: Select all
<?php
$file = 'sitecontent.xml';
$xml = simplexml_load_file($file);
if (!isset($_POST['submit'])) {
}else{
$xml->aboutpage[0]->copya = $_POST["element_1"];
$xml->asXML("sitecontent.xml");
}
?>
<form id="form_1" class="abc" method="post" action="<?php echo $PHP_SELF;?>">
<textarea id="element_1" name="element_1" class="element textarea medium"><?php echo $xml->aboutpage[0]->copya;?></textarea>
<input id="saveForm" class="button_text" type="submit" name="submit" value="Save" />
</form>
Code: Select all
$xml->aboutpage[0]->copya = "<![CDATA[" . $_POST["element_1"] . "]]>";and I'm having problems with " turning into \"<![CDATA[This is the about page text now edited.]]>
Someone please help, please explain it all to me....