0

Error我有一个 XML 文件,我想从我的 NAnt 脚本中搜索这个词。如果这个error词确实存在,它会回应那个error exist

到目前为止,我没有找到任何合适的方法。有人有什么主意吗?

4

1 回答 1

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
于 2013-07-04T04:00:00.123 回答