开发者

How to parse a xml by ANT

开发者 https://www.devze.com 2022-12-21 04:22 出处:网络
trying to build a project set file and checkout these projects: <psf> <project ref=\"version,url,name\"/>

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>

now I need extract url and name from each project tag. I used

<xmlproperty file="example.psf" collapseAttributes="true" />

but when I

<echo>$psf.project.ref</echo>,

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 someo开发者_StackOverflowne help me with this? thanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消