How to convert the following string to xml ?
var query = @"<Cars><Car manufacturer='lindo'/> <Car manufacturer='Opera'/></Cars>"; As it is a string i can't apply the extension method .cast() to convert it to XDocument or XElement.
Use the XDocument.Parse method.
Try
var queryXml = "<?xml version=\"1.0\"?>" + query; var xdoc = new XmlDocument(); xdoc.LoadXml(queryXml); (Cars will be your root element).
</Cars>