Finding element in XDocument?

前端 未结 7 1603
眼角桃花
眼角桃花 2020-12-02 20:02

I have a simple XML


  
    greatest Band
            


        
7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 20:38

    The Elements() method returns an IEnumerable containing all child elements of the current node. For an XDocument, that collection only contains the Root element. Therefore the following is required:

    var query = from c in xmlFile.Root.Elements("Band")
                select c;
    

提交回复
热议问题