c# - Linq to XML - Trying to select multiple nodes -
c# - Linq to XML - Trying to select multiple nodes -
i working xml close this:
<?xml version="1.0"?> <root> <section> <group1> <node name="something" value="some value"/> <node name="something" value="some value"/> </group1> <group2> <node name="something" value="some value"/> <node name="something" value="some value"/> </group2> </section> <section> <group1> <node name="something" value="some value"/> <node name="something" value="some value"/> </group1> <group2> <node name="something" value="some value"/> <node name="something" value="some value"/> </group2> </section> </root>
i want select group1 , group2 elements linq query. help appreciated.
try this:
var doc = xdocument.parse(xmlstring); var groups = doc.descendants("section").elements().where(e => e.name.localname.startswith("group")); console.write(groups.count());
to find grouping comes from, parent of xelement.
c# xml linq
Comments
Post a Comment