2011-04-11 52 views
4

我似乎无法工作,你将如何改变以下的web.config改造和位置元素

<configuration> 
<location path="hello123"> 
<.../> 
</location> 
</configuration> 

<configuration> 
<location path="world321"> 
<.../> 
</location> 
</configuration> 

不除去第一和添加第二。任何帮助,这将是伟大的。

感谢

+0

你在做什么改造?它是某种类型的XSLT还是代码? – 2011-04-11 04:26:52

+2

VS2010有内置 - 请参阅http://msdn.microsoft.com/en-us/library/dd465326.aspx – Chaos 2011-04-11 04:31:42

+0

我想避免删除然后添加的原因是因为允许/拒绝条件可能会改变位置元素,我不想更改web.config和转换文件。希望这是有道理的。 – Chaos 2011-04-11 04:32:56

回答

6

您可以使用SetAttributes,像这样:

<?xml version="1.0"?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <location path="world321" xdt:Transform="SetAttributes(path)" > 
    </location> 
</configuration> 

您可以在AppHarbor web.config transformation tester测试这个和其他的转换。

+0

谢谢,对! – Chaos 2012-02-19 19:35:59

+3

你也可以右键点击Web.Config.Release并选择'预览变换'(在VS2012中肯定和可能VS2010) – 2013-05-14 22:33:58