How can I save to string from linq to xml?

jazzbaileys

New Member
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:\[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); }\[/code\]
 
Back
Top