# Monday, February 07, 2011
« More adventures in hosting - Why I would... | Main | WinForm Tip: Dynamically change the font... »
Been a while, but I have a backlog of tips I will try to get posted. Here's one I found useful when I was writing a Twitter interface. I needed to convert an XmlDocument to an XDocument so I could use LINQ to XML to quickly find what I needed. Here's the function I used to do it:

        public static XDocument DocumentToXDocumentReader(XmlDocument doc)
        {
            return XDocument.Load(new XmlNodeReader(doc));
        }
However, you could easily re-write this as an extension method of an XmlDocument as well. Yes, I am a big fan of extension methods.

        public static XDocument DocumentToXDocumentReader(this XmlDocument doc)
        {
            return XDocument.Load(new XmlNodeReader(doc));
        }