ratsstack
ratsstack

Reputation: 1021

Find/replace multiple lines in Notepad++

I have hundreds of xml files that have different types of IDs e.g. submitter, requester, agent etc. I want to do a find/replace just the value for the Requester ID. XML is displayed thus:

<Submitter>
    <ID>1578642S</ID>
</Submitter>

<Requester>
    <ID>1748791R</ID>
</Requester>

<Agent>
    <ID>198791A</ID>
</Agent>

Upvotes: 0

Views: 605

Answers (2)

Kerwin
Kerwin

Reputation: 1212

Find:

<Requester>\s*<ID>\w+</ID>\s*</Requester>

Replace:

<Requester>\n<ID>newID</ID>\n</Requester>

Upvotes: 2

PabTorre
PabTorre

Reputation: 3107

This sounds like a task for xpath, not for regex or find-replace. Since you are navigating an xml to find a particular tag and replace it's text value, not finding a text pattern. an xpath code like

'//Requester/ID/*' 

should get you all instances of Requester/ID in your XML... you'll just need to wrap it in a script (of your prefered language) to iterate over the documents and replace the values and you'll be done in no time.

Upvotes: 0

Related Questions