XmlDocument from LINQ to XML query

XmlDocument from LINQ to XML query

I am loading an XML document into an XDocument object, doing a query and then returning the data through a web service as an XmlDocument object.

The code below works fine, but it just seems a bit smelly. Is there a cleaner way to take the results of the query and convert back to an XDocument or XmlDocument?

            XDocument xd = XDocument.Load(Server.MapPath(accountsXml));                   var accounts = from x in xd.Descendants("AccountsData")                        where userAccounts.Contains(x.Element("ACCOUNT_REFERENCE").Value)                        select x;          XDocument xd2 = new XDocument(             new XDeclaration("1.0", "UTF-8", "yes"),             new XElement("Accounts")                        );          foreach (var account in accounts)             xd2.Element("Accounts").Add(account);          return xd2.ToXmlDocument(); 

Common Lisp Exercises/Problems [closed]


Change an editable-text value in Allegro CL
The fact that you are putting an XDeclaration into your response smells a bit funny to me, too.

Why is consing in Lisp slow?
Lexical closures over macrolet?
Why are you building XML to return through the web service layer? The .NET web services layer, whether you use WCF or ASMX, will do the XML serialization for you.

How does Lisp let you redefine the language itself?
What features is lisp lacking? [closed]
You can return a strongly-typed object, and it is serialized for you.

Lisp simple question
How to process input and output streams in Steel Bank Common Lisp?


Since this is just for a proof of concept application I wil just live with this code for now.

THe live application would be connecting directly to a database so I would not have to pull my data from an xml file, query and then push it out again as xml..

84 out of 100 based on 84 user ratings 834 reviews