将Web响应从JSON转换为XML

时间:2021-03-19 23:44:16

I created in asmx logic i get return data in json but i need to convert to xml format below the if condition code logic

我在asmx逻辑中创建了我在json中获取返回数据但我需要在if条件代码逻辑下面转换为xml格式

 if (providers[1] == Portal.*****.ToString())
    {
    CookieContainer cookie = new CookieContainer();
    var Session = obj1.GetRequest(cookie);
    var MmtHotelid = obj1.Login("**********", "******", ref hotelid,cookie);
    var ListGetRoomtype = obj1.GetRoomTypes(MmtHotelid, Session);
    var list1 = obj1.GetRoomAvail(MmtHotelid, fromdate, todate, ListGetRoomtype, Session);
    listgetinv.InvetorYDetails.Add(list1);
    }

1 个解决方案

#1


0  

var CtRateXml = new XElement("Provider", new XAttribute("Id", Portal.*****enter code here), from c in listgetinv select new XElement("RoomType", new XAttribute("Name", c.RoomName), from od in c.cleartriprate select new XElement("Rate", new XElement("Date", od.Date), new XElement("SingleRate", od.SingleSellRate), new XElement("DoubleRate", od.DoubleSellRate) )));

var CtRateXml = new XElement(“Provider”,新的XAttribute(“Id”,Portal。*****在此处输入代码),来自listgetinv中的c选择新的XElement(“RoomType”,新的XAttribute(“Name”,c。 RoomName),来自c.cleartriprate中的od选择新的XElement(“Rate”,新的XElement(“Date”,od.Date),新的XElement(“SingleRate”,od.SingleSellRate),新的XElement(“DoubleRate”,od。 DoubleSellRate))));

#1


0  

var CtRateXml = new XElement("Provider", new XAttribute("Id", Portal.*****enter code here), from c in listgetinv select new XElement("RoomType", new XAttribute("Name", c.RoomName), from od in c.cleartriprate select new XElement("Rate", new XElement("Date", od.Date), new XElement("SingleRate", od.SingleSellRate), new XElement("DoubleRate", od.DoubleSellRate) )));

var CtRateXml = new XElement(“Provider”,新的XAttribute(“Id”,Portal。*****在此处输入代码),来自listgetinv中的c选择新的XElement(“RoomType”,新的XAttribute(“Name”,c。 RoomName),来自c.cleartriprate中的od选择新的XElement(“Rate”,新的XElement(“Date”,od.Date),新的XElement(“SingleRate”,od.SingleSellRate),新的XElement(“DoubleRate”,od。 DoubleSellRate))));