如何使用MSDeploy Parameters.xml文件更改命名空间中的XML元素? [英] How to change an XML element in a namespace with MSDeploy Parameters.xml file?

查看:93
本文介绍了如何使用MSDeploy Parameters.xml文件更改命名空间中的XML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用MSDeploy更改 Web.config 中的元素.我的 Parameters.xml 文件:

I can't change an element in Web.config with MSDeploy. My Parameters.xml file:

<parameterEntry
  kind="XmlFile"
  scope="\\web.config$"
  match="//spring/objects/object[@id='CultureResolver']/@type" />

Web.config 的相关部分:

<spring>
    <objects xmlns="http://www.springframework.net">

        <object id="CultureResolver" type="Spring.Globalization.Resolvers.SessionCultureResolver, Spring.Web">
             <!--configure for server--> 
            <property name="DefaultCulture" value="en" />
        </object>
    </objects>
</spring>

推荐答案

问题是<objects/>元素上的名称空间声明.您的XPath查询没有匹配项,因为没有<objects/>元素具有空的名称空间(这是查询要查找的内容).

the problem is the namespace declaration on the <objects/> element. Your XPath query doesn't have a match because there is no <objects/> element with an empty namespace (which is what the query is looking for).

现在,在XPath中指定XML名称空间是一个棘手的问题(在这种情况下,这甚至是不可能的),所以我建议您改用以下表达式:

Now, specifying XML namespaces in XPath is a tricky issue (in this case it's even impossible), so I'd suggest you use this expression instead:

"//spring/*/*[@id='CultureResolver']/@type"

HTH ...

这篇关于如何使用MSDeploy Parameters.xml文件更改命名空间中的XML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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