ant - Get XML property when there is more than one property that matches -


i have xml file this:

<vrmlist>     <vrm version="4" product="prod1" platform="windows"/>     <vrm version="1" product="prod1" platform="web"/>     <vrm version="6" product="prod2" platform="windows"/> </vrmlist> 

the file used other purposes changing it's structure difficult. access version each item independently using <xmlproperty> task.

example

<xmlproperty file="test.xml"/>  <target name="test">     <echo>version: ${vrmlist.vrm(version)}</echo> </target> 

results in

test:      [echo] version: 4,1,6 

what want able access properties each <vrm> independently given product , platform can use in build file.

example of want (does not work):

<echo>${vrmlist.vrm[@product="prod1" , @platform="windows"](version)}</echo>  test:     [echo] version: 4 

is possible?

similar question: ant xmlproperty task. happens when there more 1 tag same name?

the free, third-party xmltask library can extract xml values xpath:

build.xml

<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.xmltask"/> <xmltask>     <fileset file="src.xml"/>     <copy         path="/vrmlist/vrm[@product='prod1' , @platform='windows']/@version"         property="vrm.version"/> </xmltask> <echo>vrm.version : ${vrm.version}</echo> 

output

run:      [echo] vrm.version : 4 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -