我想从下面的代码中提取版本号:
<?xml version="1.0" encoding="UTF-8"?>
<Include>
<?define ProductVersion = "1.0.0.0" ?>
</Include>我希望输出是:1.0.0.0,可以这样做吗?
发布于 2013-07-02 17:53:38
如果您使用Visual Studio创建基于WIX的安装程序,那么您可以在.wixproj文件中定义ProductVersion变量。
<Target Name="BeforeBuild">
<PropertyGroup>
<DefineConstants>ProductVersion=1.0</DefineConstants>
...
</PropertyGroup>
</Target>这可以通过$(var.ProductVersion)从.wxs文件中访问。现在可以使用XPath从.wixproj文件中读取DefineConstants的值。这会让你得到ProductVersion = "1.0.0.0"
发布于 2013-07-02 16:37:17
您可以使用processing-instruction()节点筛选器访问处理指令内容。处理指令中没有定义语义,因此不能直接查询“属性值”。
您可以使用此XPath (1.0)查询通过字符串处理来获取值:
substring-before(substring-after(/Include/processing-instruction(), '"'), '"')https://stackoverflow.com/questions/17418750
复制相似问题