2

I am working on a .Net project which updates .config files using xsl.transform. It works perfectly with a .config file which has <configuration> node, but it does not update the .config file with <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> node. It does not give an error and copies everything from the .config file, but it does not update the desired element.

So here is a short example between the .config files:

-this is updated:

<configuration>
  <configSections>
    -sections-
  </configSections>
  -settings-
</configuration>

-this is not updated:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <configSections>
    -sections-
  </configSections>
  -settings-
</configuration>

Is there a solution to update the .config files with the xmlns attribute of the configuration element?

Thank you.

Miklos
  • 63
  • 5
  • 5
    You have to [understand XML namespaces](http://www.xml.com/pub/a/1999/01/namespaces.html). The elements in those two XML files actually have completely different names due to the second having a default namespace declaration (`xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"`). It's as if you added a prefix to every element name in the second XML file. You have to adjust your XSLT to match against both cases (generally prefered), or write your XSLT such that it disregards the namespaces (occasionally justified). Show your XSLT to receive more specific guidance. – kjhughes Jul 13 '15 at 14:38

0 Answers0