You need to use the nodeindex parameter of xmlpeek to control which instance 
you are returning.  However, I’m not quite sure how you’d find out how many 
instances there are to loop through dynamically.  Maybe some if condition on 
the returned value and a loop of sorts

 

-Steve

 

From: Fabio Gil [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 16, 2008 11:53 AM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] xmlpeek - Multiple nodes found with the XPathexpression

 

Hello,

I'm spinning my wheels with this issue and don't know how to solve it. I have 
an XML file that contains the name of the client I will build my app for. 

This is an excerpt of the XML file:

                <client>
                    <clientname>client1</clientname>
                    ...
                </client>
                <client>
                    <clientname>client2</clientname>
                    ...
                </client>
                <client>
                    <clientname>client3</clientname>
                    ...
                </client>

I have written a small Nant script to read from the file and send a message to 
the console

        <xmlpeek file="${config.file}" xpath="/some_stuff/client/clientname" 
            property="client.name" /> 
        <echo message="client.name: ${client.name}"/>

What I've got as a response is

  [xmlpeek] Peeking at 'myxmlfile.xml' with XPath expression 
'/some_stuff/client/clientname'.
  [xmlpeek] Found '6' nodes with the XPath expression 
'/ifast_desktop/distribution/release/installsh
ield/client/clientname'.
     [echo] client.name: client1

BUILD SUCCEEDED

I need to be able to use client.name as a parameter for my build but ultimately 
I am only getting the first appearance of the clientname.

Is there a way to do what I am trying to do?

Thanks very much!

-------------------------------------------------------------------------
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