我需要一些帮助来循环通过一个 xml 文件,我设法使用 xmlproperty 获取节点,但我正在努力解决如何在有多个参数的情况下循环它们。
所以这里是格式:
<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>
我想循环这个,所以我可以得到以下输出:
1 1 1 1 1 1 2 2 2 2 2
解决方案:
<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>