.net - How can I save to string from linq to xml? -


i want save node output string can things later. how it? when try use stringbuilder() writes whole xml file string instead of chosen node.

here code:

xdocument xmldoc = xdocument.load("file.xml");          var q = c in xmldoc.descendants("parent")                 select (string)c.element("child");         foreach (string child in q)         {             console.writeline("site: " + child);         } 

difficult tell after here. saying above code want, except want store child nodes content local var ?

if so...

        var sb = new stringbuilder();         xdocument xmldoc = xdocument.load("file.xml");          var q = c in xmldoc.descendants("parent")                 select (string)c.element("child");         foreach (string child in q)         {             sb.appendline("site: " + child);         }          var result = sb.tostring(); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -