Skip to main content
4 of 4
Formatting, minor re-tag
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

How to replace, in an XML file, specific strings of characters in some specified tags with other strings of characters embedded in tags

I need to replace, in an XML file, specific strings of characters in some specified tags with other strings of characters embedded in tags.

Example searching every occurance of an example, that needs to be replaced by <b>a test</b> only if it is within the <a> ... </a> tag (inside other tags):

  • Input example:
    <c>This is an example. <a>This is an example;</a></c>
    
  • Desired output:
    <c>This is an example. <a>This is <b>a test;</b></a></c>
    
Matt5
  • 87
  • 1
  • 5