c# - Trying to get the values of all child nodes -


my xml looks this:

<names>     <goodnames>         <name>alpha</name>         <name>beta</name>     </goodnames>     <badnames>         <name>blabla</name>     </badnames> </names> 

now trying value of child nodes belong goodnames or badnames. code i've tried far this:

var goodnames = el in doc.root.elements("goodnames") select el.element("name"); 

unfortunately, returns first element, in case alpha. however, i'd name elements.

if want names need this:

var allnames =     e in doc.root.descendants("name")     select e.value; 

if want names or bad names, try kind of thing:

var goodnames =     el in doc.root.elements("goodnames")     n in el.elements("name")     select n.value; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -