replace text in XML object using a sequence of tags as input
Hi, I need to write an apparently very simple function that replaces a text between tags in an XML object receving as input the sequence of tags to identify the element, but I miss one point.
I travel through the XML tree using a element variable like
| Code: |
| element = element.child(n) |
using at each step the tags provided as input to decide the value of "n". Now, when I reach the tags that contain the text to be replaced, what to do? If I use
| Code: |
| element.replace(0, newValue) |
I replace the text just in element not in the original object...
For example having
<publishing_date>
<year>2002</year>
<month>Jan</month>
<success_date>
<year>2004</year>
<month>Feb</month>
</success_date>
I want to call a function like
replace(["success_date", "month"], "Mar")
and have an XML object where the second occurence of Feb is replaced with "Mar"
Any suggestion on this easy task?
Thanks a lot
Giuse