How to Convert XML Response of a Third-Party Service into JSON in WCF?

pauloricardo

New Member
I am converting a Third-Party Service Response(XML) into JSON format by using JSON.NET.The Code i have tried so far,\[code\] IEnumerable<XElement> xe; IEnumerable<XElement> xe1; List<XElement> ele = new List<XElement>(); using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { XNamespace ns = "http://www.opentravel.org/OTA/2003/05"; XDocument xd = XDocument.Load(response.GetResponseStream()); xe = xd.Root.Descendants(ns + "PricedItineraries").ToList(); ele = new List<XElement>(); foreach (XElement b in xe) { ele.Add(b); }\[/code\]}In above Code, How to convert the ele into JSON format ?And I have Converted XMLdocument into JSON by using the following way,\[code\] Newtonsoft.Json.JsonConvert.SerializeXmlNode(xdoc);\[/code\]Please let me know if you need more information.
 
Back
Top