I ran into this issue *so* many times that I obtained the <xmllist> task 
and source from:

http://weblogs.asp.net/soever/archive/2006/12/01/nant-xmllist-command-updated.aspx

and modified the code so that if the final nodename specified is "*", 
all nodenames are returned in a comma-separated list.

Then I just use a <foreach item="String" delim="," ...> to go back and 
fetch each node explicitly.  The <xmllist> task also gives you many 
other advantages; enough that I don't use <xmlpeek> any more.

Example:

I have an XML file driving the build process that contains a collection 
of web.config modifications that need to be made after a web 
deployment.  The relevant XML nodes look like:

<ConfigMods>
    <web.config path="web.config">
        <DBname value="myDB" .../>
        <DBUser value="secretUser" .../>
        <authPath value="192.168.164.12" .../>
    </web.config>
</ConfigMods>

and I do the following to process the list:

<xmllist file="configDirectives.xml" xpath="/ConfigMods/web.config/*" 
property="web.config.names"/>
<foreach item="String" delim="," in="${web.config.names}" property="name">
    <xmllist file="configDirectives.xml" 
xpath="/ConfigMods/web.config/${name}/@value" property="value"/>
    <echo>  making ${name} modification; changing value to ${value}..</echo>
</foreach>

I use this method *a lot*!   It allows me to drive repetitive processes 
from my XML data.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to