c# Reading XML comment using XDocument

前端 未结 3 1376
太阳男子
太阳男子 2020-12-21 12:53

How to read xml comment when using XDocument?

XDocument doc = XDocument.Load(\"joker.xml\");
 foreach (XElement element in doc.Descendants(\"server\"))
              


        
3条回答
  •  生来不讨喜
    2020-12-21 13:37

    The Node object is the primary data type for the entire DOM.

    A node can be an element node, an attribute node, a text node, or any other of the node types explained in the "Node types" chapter.

    An XML element is everything from (including) the element's start tag to (including) the element's end tag.

         XDocument xdoc = XDocument.Load("");
           foreach (var node in xdoc.Descendants("servers").Nodes())
            {
    
                if (node is XComment)
                {
                    //THEN  READ YOUR COMMENT 
    
                }
    
            }
    

提交回复
热议问题