ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jful...@ruminate.co.uk
Subject Re: Find value between xml tags
Date Thu, 18 Nov 2004 13:49:59 GMT
"Sanjeev_Das" <Sanjeev_Das@infosys.com> wrote ..
> 
> Hi All,
> 
> I need to find out the value present in between the xml tags. Is there
> any specific task in Ant to do so? If not can anyone suggest a
> workaround.

you could use antcontrib's regular expression capabilities in its propertyregex task.....the
following is untested though!

<target name="matchxml" description="match xml using regular expression">

<!-- load xml file into property -->
<loadfile property="xml.conf"
      srcFile="conf/application.properties.xml"/>

<!-- match <test> </test> element -->
<propertyregex property="output"
              input="xml.conf"
              regexp="&lt;test&gt;([^\.]*)&lt;test&gt;"
              select="\1"
              casesensitive="false" />

<!-- print out the value -->
<echo message="${output}"/>

</target>

note my regex is untested...though it should be something like this...cant remember how I
dealt with the entity issues before.

hth, Jim Fuller


Mime
View raw message