c# - Little utility to add element in .config app file -
i need make little utility upgrade xml .config c# application file outside application.
i need add element:
<?xml version="1.0"?> <configuration> ... ... <startup uselegacyv2runtimeactivationpolicy="true"> <supportedruntime version="v4.0" sku=".netframework,version=v4.5.2"/> </startup> </configuration>
wich easy way?
i use xslt. example:
source
<?xml version="1.0"?> <configuration> <somexml/> </configuration>
transformation
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output encoding="utf-8" indent="yes" method="xml"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="configuration"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> <startup uselegacyv2runtimeactivationpolicy="true"> <supportedruntime version="v4.0" sku=".netframework,version=v4.5.2"/> </startup> </xsl:copy> </xsl:template> </xsl:stylesheet>
target
<?xml version="1.0" encoding="utf-8"?> <configuration> <somexml/> <startup uselegacyv2runtimeactivationpolicy="true"> <supportedruntime version="v4.0" sku=".netframework,version=v4.5.2"/> </startup> </configuration>
Comments
Post a Comment