Anyone know off the top of their heads how to convert a System.Xml.XmlNode to System.Xml.Linq.XNode?
I've never tried, but my first thought would be something like:
XmlNode myNode;
XNode translatedNode = XDocument.Parse(myNode.OuterXml);
Eric White's blog is the place to be for cool XML/XLINQ conversions and such. I know this question pre-date's the post but I found it while looking at some other Q, so maybe people still come across this a fair amount. His blog has plenty of optimized LINQ, like I suspect the .Parse() call for the origional responce is non-optimal, well in-fact I know it is not.
Parse is going to require that the XML be loaded up in one shot, Eric used extension methods which process the XML conversion with XmlReader/Writer's. Those methods are able to stream the input, so if your XML is of any substantional size, you have to use them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With