Grosmar
Grosmar

Reputation: 167

Ant Iterate through files and search for expressions

In Ant I would like to iterate through files and in each file's content i'm looking for some regexp. From the matches of the regexp I want to create a new file.

ie. I have 3 files:

A.txt

<root>
<node type="com.module.SomeModule" />
<node name="Test" />
</root>

B.txt

<root>
<node name="Apple" />
<node type="com.module.SomeModule2" />
<node type="com.module.SomeModule3" />
<strangenode id="green" />
</root>

C.txt

<root>
<node name="Apple" />
<strangenode id="green" />
</root>

And i want to create a file like this:

references.txt

com.module.SomeModule
com.module.SomeModule2
com.module.SomeModule3

Thanks a lot!

Upvotes: 0

Views: 77

Answers (1)

Stavr00
Stavr00

Reputation: 3314

Use an XSLT task to parse the XML and generate a set of files containing the desired values, then use concat task to assemble references.txt from the set of files output from XSLT.

Upvotes: 1

Related Questions