0

i have a little problem with useing regular expressions in ANT. I have two XML files which have a strcture like that:

XML file 1:

<testtag id="2234">
<blabla>data</blabla>
    </testtag>

XML file 2:

<testtag id="2234">
    <blabla>data2</blabla>
        </testtag>

Now i need an regular expression for ANT which selects all data between the testtags which have the same id and put them together in one final XML file. I tried a few differnt regular expression but nothing worked..

merlinsson
  • 65
  • 8

2 Answers2

1

Do not use regular expressions to parse XML.

If you want to know why, see for example:

Can you provide some examples of why it is hard to parse XML and HTML with a regex?

Why it's not possible to use regex to parse HTML/XML: a formal explanation in layman's terms

and of course the classic:

RegEx match open tags except XHTML self-contained tags

Community
  • 1
  • 1
Michael Kay
  • 156,231
  • 11
  • 92
  • 164
0

The only way I can imagine you'd do it, is with this:

<testtag id="2234"[^>]*>(.*?)<\/testtag>

Vasili Syrakis
  • 9,321
  • 1
  • 39
  • 56