I want to save my node output to a string so I can do things with it later. How would I do it? When I try to use Stringbuilder() it writes the whole XML file to string instead of just my chosen node.
Here is my code:
XDocument xmlDoc = XDocument.Load("file.xml");
var q = from c in xmlDoc.Descendants("Parent")
select (string)c.Element("Child");
foreach (string Child in q)
{
Console.WriteLine("Site: " + Child);
}
Difficult to tell what you are really after here. Are you saying that the above code is what you want, except that you want to store the child nodes content into a local var ?
if so…