Manipulating XML element data, softcode element names
Posted: Tue Dec 16, 2008 5:57 am
Hi All,
Wonder if you can help.
I know that you can update XML element data by hardcoding the element names, eg:
Problem I have is that the code I am writing is going to be used to process many different XML files and as such I won't know the element names until runtime and as such I can't hard code the updates as above.
So my query is this: is there a way to update element data using $variables to identify the element names?
Apologies if this is a repeat post.
Many thanks
Dave
Wonder if you can help.
I know that you can update XML element data by hardcoding the element names, eg:
Code: Select all
$xml = new SimpleXMLElement($xmlstr);
$xml->element1->element2->element3 = 'Hello World';
So my query is this: is there a way to update element data using $variables to identify the element names?
Apologies if this is a repeat post.
Many thanks
Dave