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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -