Add namespace in xpath in XmlFile Element (Wix Uti

2019-07-26 05:00发布

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

1条回答
▲ chillily
2楼-- · 2019-07-26 05:57

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.

Edit: 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 [\[]...[\]].

查看更多
登录 后发表回答