如何通过 ANT 解析 xml [英] How to parse a xml by ANT
问题描述
尝试构建项目集文件并检查这些项目:
trying to build a project set file and checkout these projects:
<psf>
<project ref="version,url,name"/>
<project ref="version,url,name"/>
<project ref="version,url,name"/>
</psf>
现在我需要从每个项目标签中提取 url 和名称.我用过
now I need extract url and name from each project tag. I used
<xmlproperty file="example.psf" collapseAttributes="true"/>
但是当我
,
我得到了这样的东西,而不是控制每一行上的每个标记:
I got something like this, instead of having control to each token on each line:
version,url,name,version,url,name,version,url,name
有人可以帮我解决这个问题吗?谢谢
Can someone help me with this? thanks
推荐答案
我用过这个 http://www.oopsconsultancy.com/software/xmltask/ 过去用ANT处理XML.我将获取每个单独属性的快速示例放在一起.
I've used this http://www.oopsconsultancy.com/software/xmltask/ in the past to process XML with ANT. I threw together a quick sample of getting each individual attribute.
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
<xmltask source="test.xml">
<call path="psf/project">
<param name="ref" path="@ref"/>
<actions>
<echo>ref = @{ref}</echo>
</actions>
</call>
</xmltask>
不确定这是否适合您的需求,但它确实可以单独获取属性值.
Not sure if this will suit your needs, but it does work to get the attribute values individually.
这篇关于如何通过 ANT 解析 xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!