I have a XML see blow,I want to read the revision recuresively.I had read
Archives history.I can use nodeindex and foreach to read.but in the history it
must already know how many nodeindex are there in xml file.I write a script to
count nodeindex.
I have problems
1.may I use dynamic xmlpeek recursively?
2.how can I use method parameter in the script? I need use scirpt with
parameters with input filename and xpath
I don't know how to reply mail by subject.Thanks for help here.:)
xml
<?xml version="1.0" encoding="utf-8"?>
<list>
<dirset>
<revision>2</revision>
<basedir>d:\workspace\Edwin2\</basedir>
<todir>D:\release2</todir>
</dirset>
<dirset>
<revision>3</revision>
<basedir>d:\workspace\Edwin3\</basedir>
<todir>D:\release3</todir>
</dirset>
</list>
nant task using xmlpeek
<project default="all">
<target name="all">
<foreach item="String" in="0,1" delim="," property="index">
<xmlpeek file="FileList.xml" property="revision" nodeindex="${index}"
xpath="/list/dirset/revision" />
<echo message="${revision}" />
</foreach>
</target>
</project>
nant task script
<project default="all">
<target name="all">
<script language="C#" prefix="XMLUtil" >
<references>
<include name="System.Xml.dll" />
</references>
<imports>
<import namespace="System.Xml" />
</imports>
<code>
<![CDATA[
[Function("XMLNodeCount")]
public static string XMLNodeCount() {
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("FileList.xml");
XmlNodeList elements = xmlDoc.SelectNodes("//list/dirset/revision");
int i = 0;
foreach (XmlElement element in elements) {
i++;
}
return i.ToString();
}
]]>
</code>
</script>
<echo message='${XMLUtil::XMLNodeCount()}'/>
</target>
</project>
______________________________________________________________________________________________________
付費才容量無上限?Yahoo!奇摩電子信箱2.0免費給你,信件永遠不必刪! http://tw.mg0.mail.yahoo.com/dc/landing
-------------------------------------------------------------------------
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