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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -