ant contrib - ant Task for or foreach loop in xml files -


i need on looping through xml file manged nodes using xmlproperty struggling on how loop through them there more 1 params.

so here format:

<problems>       <problem>         <rule>1</rule>         <problemdescription>1</problemdescription>         <sourcefile>1</sourcefile>         <line>1</line>         <column>1</column>         <severity>warning</severity>      </problem>      <problem>        <rule>2</rule>        <problemdescription>2</problemdescription>        <sourcefile>2</sourcefile>        <line>2</line>        <column>2</column>       <severity>warning</severity>      </problem> </problems> 

i want loop through can following output:

1 1 1 1 1 1 2 2 2 2 2

solution:

  <target>     <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.xmltask"/>       <xmltask source="problem.xml">          <call path="/problems/problem">             <param name="rule" path="rule/text()" />             <param name="probdesc" path="problemdescription/text()" />             <actions>                 <echo>rule: @{rule}</echo>                 <echo>problem description: @{probdesc}</echo>             </actions>             </call>     </target> 

you can use xpath expression return matches given pattern. in case, value of tags.

here xpath ant task.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -