Xml 如何选择子节点而不是该子元素的整个子元素
上面的代码返回category中属性为“Arts”的所有category元素 我想要的只是类别中属性为“Arts”的类别下方的节点 不属于文字属性设计和视觉艺术类。我想整个类别节点像下面Xml 如何选择子节点而不是该子元素的整个子元素,xml,linq-to-xml,Xml,Linq To Xml,上面的代码返回category中属性为“Arts”的所有category元素 我想要的只是类别中属性为“Arts”的类别下方的节点 不属于文字属性设计和视觉艺术类。我想整个类别节点像下面 xDoc.Descendants("category").Where(a => a.Attribute("text").Value == "Arts").Descendants("category") 给你,希望你还需要这个: <category> <category tex
xDoc.Descendants("category").Where(a => a.Attribute("text").Value == "Arts").Descendants("category")
给你,希望你还需要这个:
<category>
<category text="Design"/>
<category text="Visual Arts"/>
<category>
<category>
<category text="Design"/>
<category text="Visual Arts"/>
<category>
string category = "Business";
var children = xDoc.Root.Elements("category").Where(a => a.Attribute("text").Value == category).Elements();