I need to comment and uncomment a XML node with child nodes in a file using System.XML
.
Starting XML:
<?xml version="1.0" encoding="utf-8"?>
<test>
<!--comment...-->
<childTest>
<childchildTest>5<childchildTest/>
</childTest>
</test>
Commenting the whole node wouldn't be a problem and easy to achieve like in this example. But my problem is that I've already got some comments inside the node and nested comments aren't allowed per XML rules.
That means I would have to comment out line by line of the XML file so I would not destroy the XML file structure with nested comments.
Desired output:
<?xml version="1.0" encoding="utf-8"?>
<!-- <test> -->
<!--comment...-->
<!-- <childTest> -->
<!-- <childchildTest>5<childchildTest/> -->
<!-- </childTest> -->
<!-- </test> -->
Is it possible to achieve this with System.XML or would I have to do this with regex for example?