My application reads values from an xml file which I write everytime when I execute the application.
This is how I made comments of my lines:
XmlComment DirCom = doc.CreateComment("Comment")
XmlElementName.AppendChild(DirCom);
And It works fine, But now I need to comment the XML element, And the above doesn't work. My final result should be like:
<!--<name>David</name>-->
using C# and the XML document library.
To comment an xml node I would do it like this :
XmlComment DirCom = doc.CreateComment(XmlElementName.OuterXml);
doc.InsertAfter(DirCom, XmlElementName);
doc.RemoveChild(XmlElementName)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.