在 XmlFile 元素的 xpath 中添加命名空间(Wix Util 扩展) [英] Add namespace in xpath in XmlFile Element (Wix Util Extension)

查看:31
本文介绍了在 XmlFile 元素的 xpath 中添加命名空间(Wix Util 扩展)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

wix 中 XmlFile 元素的 ElementPath 属性接受一个 xpath 来选择目标.如何在此 xpath 中包含命名空间前缀?

The ElementPath attribute of XmlFile element in wix accepts an xpath to select the target. How can I include namespace prefixes in this xpath?

推荐答案

根据这个问题条目 这似乎是一个错误或更好:一个未实现的功能,因为最终存在的默认命名空间不会被 util:XmlFile-元素公开.
根据此条目中的第一条注释,您可以使用 util:XmlConfig 解决此问题,该方法应在空命名空间中查找所需节点/元素.

According to this issue entry it seems to be a bug or better: a not implemented feature, as an eventually existing default namespace is not exposed by the util:XmlFile-element.
According to the first comment in this entry you can work around this issue by using util:XmlConfig which should look in the empty namespace for the needed nodes / elements.

我找到了另一种使用它的方法:根据this SO question 通过@LarsH,您可以使用类似以下内容(我自己没有测试过,但由于它似乎是一个有效的 XPath 1.0 表达式,因此它通常应该可以工作):

I've found another method for using it: according to this SO question by @LarsH you can use something like the following (didn't test it myself, but as it seem to be a valid XPath 1.0 expression, it should normally work):

"*[local-name() = 'foo' and namespace-uri() = 'http://my.org/ns/2.0']"

记得要转义方括号,即[...]应该变成[\[]...[\]].

Remember to escape the square brackets, i.e. [...] should become [\[]...[\]].

这篇关于在 XmlFile 元素的 xpath 中添加命名空间(Wix Util 扩展)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆