我有一个关于Nant构建脚本的查询,我对NANT构建相当陌生,以防我想基于xml文件中的某些条件来运行样式
count(${skinFolder}/screens.temp.xml//ActionCollection/Item) >0
有没有办法做到这一点??
先谢谢你,悉达多
发布于 2009-08-19 09:50:24
在NAnt脚本的project节点下添加以下内容:
<script language="c#" prefix="custom">
<code>
<![CDATA[
[Function("evaluate-xpath")]
public static string EvaluateXPath(string xpath, string info)
{
System.Xml.XPath.XPathDocument xml = new System.Xml.XPath.XPathDocument(info);
return xml.CreateNavigator().Evaluate(xpath).ToString();
}
]]>
</code>
</script>然后,您可以使用以下表达式来实现您想要的结果:
if="${int::parse(custom::evaluate-xpath('count(//ActionCollection/Item)', path::combine(skinFolder 'screens.temp.xml'))) > 0}"只需注意,如果您的xml文件具有指定了名称空间的节点,那么这将不起作用。
https://stackoverflow.com/questions/1176252
复制相似问题