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
Your code selects the first
processelement from eachprocesseselement in the document — of which there is only one.To select all
processelements in the document, try this: