in reply to Changing XML Tag value in Perl Script

For tasks like this, I suggest using an XML manipulation package such as XML::Twig. (Or XML::Simple, although I have learned to prefer to use Twig because very few “simple” things stay that way for long.)

These packages will enable you to solve the problem swiftly:

  1. Decode the XML statement, getting a handle to that statement.
  2. Using the handle, issue an XPath expression which will (with no complicated code from you...!) search the XML tree for all occurrences of whatever you’re looking for.
  3. Given the list of nodes returned from that XPath-search, use the appropriate methods of those nodes to make the necessary changes ... to those nodes or, as the case may be, to their neighbors.   (The node-references that you get back from your search point to those nodes in the tree.)
  4. Convert the structure back into an output string.   Q.E.D.

It will surprise you how little code is actually required to accomplish this kind of task ... and to accomplish it quite thoroughly.   Without a doubt, the systems that your app is talking to, are using these same core libraries and techniques, no matter what language(s) they were written in.   Go and do likewise.™