-2

I've written a regex to alter some XML nodes - taking a generic node name and replacing it instead with the nodes attribute value like so: Regex

<custom-attribute attribute-id="(.*)?"\s*(>*)(.*?)</custom-attribute>

for the following xml:

<custom-attribute attribute-id="isNewtest">false</custom-attribute>

using replace regex

<$1>$3</$1>

gives output of

<isNewtest>false</isNewtest>

which is what I am looking for - however - once more than one node is introduced into the schema - e.g

<custom-attribute attribute-id="isNewtest">false</custom-attribute>
<custom-attribute attribute-id="isAnotherNewtest">false</custom-attribute>

and I run the regex, the output is:

<isNewtest">false</custom-attribute>
<custom-attribute attribute-id="isAnotherNewtest>false</isNewtest">false</custom-attribute>
<custom-attribute attribute-id="isAnotherNewtest>

which is not what I was expecting, I was hoping for:

<isNewtest>false</isNewtest>
<isAnotherNewtest>false</isAnotherNewtest>

I'm obviously missing something to do with searching through more than one node at a time or multiline selector? - Can someone point me in the right direction please? I've got to restructure a 20,000 line xml doc and not relishing the idea of doing it manually line by line..

Bodkin
  • 1

1 Answers1

0

Seems I was being blind, this works

<custom-attribute attribute-id="(.*?)"\s*(>)(.*?)</custom-attribute>
Bodkin
  • 1