c# - Get specific node from XElement using .net -
i have below xml. want <profile>
element.
<profiles> <profileinfo> <profile> <name>test</name> <age>2</age> </profile> </profileinfo> </profiles>
i tried doing
var nodes1 = nodes.elements().where(x => x.element("profiles") != null).tolist(); foreach (var node in nodes1) node.remove();
i tried value directly
var nodes = xmldocumentwithoutns.elements() .where(x => x.element("profile") != null) .tolist();
but doesn't data want. need change data want?
i result in form (representation):
<profile> <name>test</name> <age>2</age> </profile>
the following snippet value of first child profile element:
var somedata = doc.root.descendantsandself("profile").first();
the value of somedata be:
<profile> <name>test</name> <age>2</age> </profile>
Comments
Post a Comment