In C# how would I use xml.linq to grab values nested in xml?



Sorry if this has been asked I can't find it. I'm not great with XML but am trying to work with it


The xml looks like this:



<config>
<command name="name of command">
<commandoutput>TEXT</commandoutput>
</command>
</config>


basically I am trying to get where it says TEXT.


I've figured out I can get where it says "name of command" by doing



XDocument xd = XDocument.Load("config.xml");
var commandcheck = from paths in xd.Decendants(xmln)
select paths.Attribute(attrb).value
foreach(var paths in commandcheck)
{
Console.WriteLine(paths)
}


Thanks.


No comments:

Post a Comment