Ok, here's my workaround to parse this xml file, and it works! Essentially I 
just increment the node index and make a recursive target call.

<tests>
   <!--
      testRunStatus = run this test?: yes, no, or skip
   -->
   <test>
      <name>Lesson1234</name>
      <testRunStatus>skip</testRunStatus>
   </test>
   <test>
      <name>Lesson4567</name>
      <testRunStatus>yes</testRunStatus>
   </test>
   <test>
      <name>Lesson5678</name>
      <testRunStatus>no</testRunStatus>
   </test>
   <!-- This has to be the last node! -->
   <test>
      <name>*</name>
      <testRunStatus>no</testRunStatus>
   </test>
</tests>

   <!-Initial xml idx value is 0 -->
   <property name="xmlidx" value="0" />
   <target name="selectTestToRun">
      <xmlpeek file="C:\Sompath\teststoRun.xml" xpath="/tests/test/name" 
nodeindex="${xmlidx}" property="name" />
      <if test="${name != '*'}">
         <echo>name is ${name} </echo>
        <xmlpeek file="C:\Somepath\teststoRun.xml" 
xpath="/tests/test/testRunStatus" nodeindex="${xmlidx}" 
property="testRunStatus" />
         <echo>testRunStatus is ${testRunStatus} </echo>
         <if test="${testRunStatus == 'yes'}">
            <!-RUN THE TEST -->
         </if>
         <!-increment xml index -->
         <property name="xmlidx" value="${int::parse(xmlidx)+1}" />
        <!-Recursive call -->
         <call target="selectTestToRun" />
      </if>
   </target

From: Bob Archer [mailto:bob.arc...@amsi.com]
Sent: Friday, April 20, 2012 11:05 AM
To: Chris Fouts; nant-users@lists.sourceforge.net
Subject: RE: xmlpeek and multiple nodes

Not really, no.

From: Chris Fouts [mailto:chris.fo...@caemilusa.com]
Sent: Friday, April 20, 2012 10:03 AM
To: nant-users@lists.sourceforge.net
Subject: Re: [NAnt-users] xmlpeek and multiple nodes

So no canned support for this?

-chris

From: Bob Archer [mailto:bob.arc...@amsi.com]
Sent: Friday, April 20, 2012 9:59 AM
To: Chris Fouts; nant-users@lists.sourceforge.net
Subject: RE: xmlpeek and multiple nodes

In other words, if you can't get to a specific node with an XPath expression 
you really need to roll your own. That's really what it is designed for.

You could do something like what you are doing, however, you probably still 
need your own script task to get the count of matching nodes. A quick google 
find this http://bgeek.net/2005/09/19/nant-xml-node-counting/

BOb


From: Chris Fouts [mailto:chris.fo...@caemilusa.com]
Sent: Friday, April 20, 2012 9:48 AM
To: Bob Archer; nant-users@lists.sourceforge.net
Subject: RE: xmlpeek and multiple nodes

That's all I want to do, find a node and update it.

From: Bob Archer [mailto:bob.arc...@amsi.com]
Sent: Friday, April 20, 2012 9:36 AM
To: Chris Fouts; nant-users@lists.sourceforge.net
Subject: RE: xmlpeek and multiple nodes

For more than a simple find a node and update it I would recommend you write 
you own code using the script task. Or write your own task.

BOb


From: Chris Fouts [mailto:chris.fo...@caemilusa.com]
Sent: Friday, April 20, 2012 9:02 AM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] xmlpeek and multiple nodes

How can I use xmlpeek/xmlpoke to recursively peruse all the similarly named 
nodes in a file, the the <test> node below.

<tests>
   <test>...</test>
   <test>...</test>
   <test>...</test>
</tests>

This didn't help, 
http://nant.sourceforge.net/release/0.85/help/tasks/xmlpeek.html

And I found this
http://old.nabble.com/xmlpeek---Multiple-nodes-found-with-the-XPath-expression-td20017190.html

Per that page, do I really have to do this, that is hard code the indices? So 
if I add a 16th node, I'll have to change the script to add a 16th index?
<foreach item="String" in="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15" delim="," 
property="index">
   <xmlpeek file="${somefile} nodeindex="${index}" ..../>
</foreach>

So I found this 
http://www.mail-archive.com/nant-users@lists.sourceforge.net/msg11179.html
But my nant version 0.91 complains about <xmllist> being an unknown task or 
data type.

-chris

***This e-mail message is intended only for the above named recipient(s)
and may contain information that is sensitive or proprietary. If you have
received this message in error or are not the named recipient(s), please
immediately notify the sender, delete this e-mail message without making
a copy and do not disclose or relay this e-mail message to anyone.***
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to