Search code examples
xmlxpathmsdeploy

How to change an XML element in a namespace with MSDeploy Parameters.xml file?


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" />

The relevant section of 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>

Solution

  • 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).

    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...