Linq to xml : can't load all elements
Posted
by aleo
on Stack Overflow
See other posts from Stack Overflow
or by aleo
Published on 2010-06-03T11:08:19Z
Indexed on
2010/06/03
11:14 UTC
Read the original article
Hit count: 202
c#
|linq-to-xml
hello
i'm trying to load some elements from a xml file. but it XDocument.Load seems not treating xml file properly in this case, the method returns the content of the xml file as one node.
here is my xml content:
<processes>
<process>winamp</process>
<process>Acrobat</process>
<process>WinRAR</process>
</processes>
and the code that reads the file:
XDocument loaded = XDocument.Load("/process_list.xml");
var x = from a in loaded.Descendants("processes")
select a.Element("process");
foreach (var t in x)
{
Console.WritleLine(t.Value.ToString());
}
thank you
© Stack Overflow or respective owner