如何选择多个 XML标签作为XElement ,基于相同的属性进行过滤。 我有以下代码我想选择具有 action = true
的标签<root>
<first action="true">
<path>E:\Myfolder</path>
</first>
<second>
<path>C:\Users\</path>
</second>
<third action="true">
<name>Mytasks</name>
</third>
</root>
和输出喊叫就像这样
<first action="true">
<path>E:\Myfolder</path>
</first>
<third action="true">
<name>Mytasks</name>
</third>
任何人请帮助我。我使用了 FirstorDefault()但是我只在所有
中获得了一条记录答案 0 :(得分:1)
尝试一下。
$(path).find('root').find('[action="true"]')
答案 1 :(得分:0)
试试这个
xd = XDocument.Load("XML FILE PATH");
xe = xd.Root;
IEnumerable<XElement> oColl = from x in xe.Descendants() where ((string)x.Attribute("action")).equals("true") select x;