I was using some web-services that returned there values in an XmlElement. I needed to convert this XmlElement to something that I can use with LINQ. I didn't find good solutions on the internet. So I started building my own convert logic. After all kinds of solutions I ended up with creating an new XmlDocument, adding the XmlElement to the XmlDocument and then convert the innerXml of the XmlDocument to an XElement. Not really nice but it does the trick.
I've rewritten the code into a Extension Method for the XmlElement.
public static XElement ToXElement(this XmlElement xml)
XmlDocument doc = new XmlDocument();
You use the Extension Method like this:
XmlElement xmlElement = wsClient.DoWebServiceRequest();
XElement xml = xmlElement.ToXElement();
Please tell me if you have a better way of doing this!