I have a xml response with a structure ( e.g groups > subgroups > child records ) and repeats several thousand times with different values with each one.
I want to only grab subgroups whose 9 digit serial number field matches what I provide and extract them into its own file. When extracting the subgroups, it would also bring the group with it. I was hoping such a task would be possible using notepad++ and possibly through the use of regex, but not sure how I would go about in doing this.
I’m not familiar with notepad++ specifically. For my solution to work it work it would need to support multi-line regular expressions and advanced regular expression syntax (non-greedy matching). Not all text editors that support regular expressions will do either.
I would start and end with the outer tag that you want
\<subgroup\>\<\/subgroup\>escaping the special characters. To capture what is in between, I would use non-greedy matching\<subgroup\>\.*?<\/subgroup\>. Then I would add the specific serial number you are interested in\<subgroup\>\.*?123456789.*?<\/subgroup\>.If you want to find some of multiple serial numbers here use something like