Thursday, 26 February 2015

looping trough an xml file combining lists in ANT



I have this xml:



<?xml version="1.0" encoding="UTF-8"?>
<projects>
<project action="D">Project1</project>
<project action="M">Project2</project>
</projects>


I want to use ant to loop trough the projects and execute a piece of code when the action is D, and an other piece of code when the action is not D.


My progress so far is:



<target name="test">
<xmlproperty file="changeList.xml"/>
<for list="${projects.project}" param="project">
<sequential>
<echo>The project name is @{project} Action @{project.action}</echo>
</sequential>
</for>
</target>


result now is:



[echo] Project name is Project1 Action is @{project.action}
[echo] Project name is Project2 Action is @{project.action}


I understand that I have 2 separate lists and that I'm not getting the action in the result. I need to loop trough my xml file having both property's available (project name, and the action) to pass as a parameter to the next target.


No comments:

Post a Comment