I have the following code in my 'update_xml.php' file:
$xml = simplexml_load_file('content.xml');
$name = $_POST['name'];
$xml->home->main->title = $name;
$output = $xml->asXML();
...
I'm using AJAX to post data to this file:
var name = $(this).val();
$.post("update_xml.php", {name: name}, ...
All this works fine, but I also need to be able to post the specific tag to be updated too. Eg:
var name = $(this).val();
$.post("update_xml.php", {name: name, tag: '$xml->home->main->title'}, ...
$xml = simplexml_load_file('content.xml');
$name = $_POST['name'];
$tag = $_POST['tag'];
$tag = $name;
This clearly doesn't work ($tag is now a string). I've tried using eval(), to no avail, and not the best way of going about this. Any ideas?