Hello all, I have a XML file with the following contents:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<language id="English">
<page id="applications">
<word id="root_system">Root Application</word>
<word id="test_system">Test Application</word>
...
</page>
</language>
I need to edit the attributes and the text in between the word tags depending on user input, to edit the attributes tag of <word id="test_system"> I do the following:
Code:
$xml = simplexml_load_file('./languages/en.xml') or die ("Unable to load XML file!");
$xpath_query = $xml->xpath('//page[@id="applications"]/word[@id="test_system"]');
$xpath_query[0]['id'] = "XXXXXXXX";
which works as expected, nevertheless when I try to edit the text in between the tags it fails, this is the code that fails:
Code:
$xml = simplexml_load_file('./languages/en.xml') or die ("Unable to load XML file!");
$xpath_query = $xml->xpath('//page[@id="applications"]/word[@id="test_system"]');
$xpath_query[0] = "XXXXXXXX";
to edit the text in between I can do the following:
Code:
$xml = simplexml_load_file('./languages/en.xml') or die ("Unable to load XML file!");
$xpath_query = $xml->xpath('//page[@id="applications"]');
$xpath_query[0]->word[1] = "XXXXXXXX";
but this approach involves knowing the position of <word id="test_system">Test Application</word> in the array $xpath_query, instead of using xpath to search for it, does any of you know how to change the text in between the tags as easy as it is to change the attributes? (isn't that functionality a logical approach? I mean if you can change the attributes you should be able to change the text in between the tags the same way.)
Thank you very much for your help.