tags:

views:

302

answers:

1

I need to uncomment a portion of xml in a file that I am working with in NAnt. Heres a sample of the xml:

<navigation>
<!-- Navigation Section
    <something name="" />
    <something name="" />
-->
</navigation>

What I want to do is take the --> portion and move it next to "Navigation Section". A global find for --> won't work as there are many --> in the file, as well as under the navigation node. this end comment character is the last one in the navigation node.

Anyone?

A: 

It's hacky but you could do a search for the string and then work backwards from there to replace the xml comment strings with empty strings. If you can implement that in C# (regular expression would be well suited to this) then it's fairly straightforward to wrap that in a custom nant target (as I did here for a different problem).

A completely different approach would be to store the nodes in a different file and insert them into this XML file using xmlpoke. This is probably a better approach than the above but that depends on your exact circumstances.

Iain
xmlpoke is not an option in this scenario.
Sean Chambers