Ren : Sounds like a job for regular expressions, or "regex" for short. Here are
a couple of good resources. This first is introductory the second more advanced.
Good luck.
I don't think that regex is a suitable solutions for this problem because then you'll lose a lot of the flexibility of xml. Although I don't have any experience with it I would recommend you to look at a java XQuery implementation.
"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler
In general regular expressions are useless when working with tree-structured data. If you have a trivial XML document and you're willing to take the risk that the part you are changing isn't going to run into conflicts with the XML escaping rules then a regex might work, but usually the way to do that is to parse the document, change the "tag value", and serialize it out to a new document.
Paul Clapham wrote:... but usually the way to do that is to parse the document, change the "tag value", and serialize it out to a new document.
This is what I had in mind. To me the problem seemed to invite string
manipulation. Is the fact that it happens to be XML relevant? I suppose
it could be if XML libraries offer some cool tools to help.