我有一个XML文件,我想从我的NAnt脚本中搜索Error
字。如果此error
字存在,则会回显error exist
。
到目前为止,我没有找到任何合适的方法。有没有人有任何想法?
答案 0 :(得分:1)
可能会因为${ ... }
内部的混淆而感到困惑。希望这会有所帮助。
<?xml version="1.0"?>
<project name="Find a String" default="build" basedir=".">
<target name="build" description="various forms of string">
<echo message="hardcoded strings" />
<property name="stringFound" value="${string::contains('a string is a tiresome thing to search', 'tire')}" />
<echo message=" stringFound=${stringFound}" />
<echo message="property strings" />
<property name="stringToSearch" value="a property string is also a tiresome thing to search" />
<property name="findThis" value="tires" />
<property name="stringFound" value="${string::contains(stringToSearch, findThis)}"/>
<echo message=" stringFound=${stringFound}" />
</target>
</project>
这给出了
[echo] hardcoded strings
[echo] stringFound=True
[echo] property strings
[echo] stringFound=True