Question: How can I either select a comment or insert a comment using Web.config transforms?

Nowhere can I find any information on this.

I am trying to do either:
1) Insert a piece of xml (`<serviceAuthorization impersonateCallerForAllOperations="true"/>`) before an existing comment in the Web.config

OR

2) Insert a comment and xml at the end of a set of siblings:

As far as I can tell the Web.config transforms do not support xPath axes, I have tried a number of them to try and insert a node before the first comment:

```
<serviceAuthorization impersonateCallerForAllOperations="true" xdt:Transform="InsertBefore(/configuration/system.serviceModel/behaviors/serviceBehaviors/behavior[@name='behaviorOne']/serviceMetadata/preceding::comment()[1])"/>

<serviceAuthorization impersonateCallerForAllOperations="true" xdt:Transform="InsertBefore(/configuration/system.serviceModel/behaviors/serviceBehaviors/behavior[@name='behaviorOne']/child::node()[1]"/>

```

I have tried a few others, but you get the idea. I just get an error when previewing the transform.

I also can't seem to find any information on how to insert a comment. Am I missing something?

Answer: 
I believe that transformations are limited to operating on elements or attributes. At least, none of the [documentation](http://msdn.microsoft.com/en-us/library/dd465326.aspx) on xdt:Transform mentions anything that could be used to add a comment.

As for the Locator, there does seem to be *some* support for axes as I was able to use the following:

```
<spring >
<objects xmlns="http://www.springframework.net">
  <object >
    <constructor-arg index="0" type="System.Uri" value="https://example.com/test" xdt:Locator="Condition(../@name='requestConfig' and @index='0')" xdt:Transform="SetAttributes(value)"/>
  </object>
</objects>

```

when operating on the following:

```
<spring >
<objects xmlns="http://www.springframework.net">
    <object name="requestConfig" type="Example.Namespace.RequestConfig, Example" singleton ="true">
        <constructor-arg index="0" type="System.Uri" value="https://example.com/production"/>
        <constructor-arg index="1" value="45000"/>
    </object>
</objects>

```

As you can see, the above uses the parent axis in order to match the element to be transformed.
Bit late to the party but for those googling I found a bit of a workaround - if you insert a node it inserts any comments inside the node, obviously you need to remove it first. Ie:

> 
> 
> ```
>   <customErrors xdt:Transform="Remove" />
>   <customErrors mode="On" defaultRedirect="Hub/Error" xdt:Transform="Insert">
>       <!-- comment -->          
>   </customErrors>
> 
> ```
> 
> 

The downside is that it destroys the child nodes but I try and put the comment as low as possible to alleviate the damage.