Meine XML-Antwort sieht wie folgt aus:XML Antwort auf Linq
"<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<HotelAvailResponse xmlns="http://www.juniper.es/webservice/2007/">
<AvailabilityRS Url="http://xml.bookingengine.es"
TimeStamp="20130327T14:38:54.6916528+01:00"
IntCode="lCf65bPrG+x7VDLB0IquVNQgKloRA9+HOuhfHMj0BcE=">
<Results>
<HotelResult Code="7b0LYEzfsd0HH90sd" JPCode="JP003600" DestinationZone="39303" JPDCode="JPD000014">
<HotelInfo>
<Name>Hotel Test</Name>
<Description>A spacious, quiet, light and bright hotel, with a garden and fabulous views across the city.</Description>
<Images>
<Image>http://www.bookingengine.es/images/upload_p/hoteltest.jpeg</Image>
</Images>
<HotelCategory>1 1/2 Stars</HotelCategory>
<HotelType Type="SKI">Snow</HotelType>
<Address>c/tap</Address>
</HotelInfo>
<HotelOptions>
<HotelOption RatePlanCode="dcFZbKty1cJGKeRtgxIDGUZAprp1mua8ySl4iVIZ7NVKBF/PGk8lhZlN7Hcszjs2RwUR2Dxsrv5l0cZDORKz6frEmPdibqOyV2Jg4Dxz8/bF5gqPyQR8+z1LEu8LCVlS" Status="OK">
<Board Type="AD">Bed&Breakfast</Board>
<Prices>
<Price Type="S" Currency="USD">
<TotalFixAmounts Gross="353.65" Nett="353.65">
<Service Amount="321.5"/>
<ServiceTaxes Included="true" Amount="32.15"/>
<Commissions Included="true" Amount="0"/>
<HandlingFees Included="true" Amount="0"/>
<Discount Amount="-0"/>
</TotalFixAmounts>
</Price>
</Prices>
<HotelRooms>
<HotelRoom Units="1" Source="1" AvailRooms="12">
<Name>Double Room</Name>
<RoomCategory Type="DBL">Double Standard</RoomCategory>
</HotelRoom>
<HotelRoom Units="1" Source="2" AvailRooms="45">
<Name>Single</Name>
<RoomCategory Type="SGL">Single Standard</RoomCategory>
</HotelRoom>
</HotelRooms>
</HotelOption>
<HotelOption RatePlanCode="dcFZbKty1cJGKeRtgxIDGUZAprp1mua8ySl4iVIZ7NVKBF/PGk8lhZlN7Hcszjs2RwUR2Dxsrv5l0cZDORKz6frEmPdibqOyV2Jg4Dxz8/bmoX041DU9+3D3nHCEB/6vYKbVtJR2qaHwW9VnnWl/KA==" Status="OK">
<Board Type="AD">Bed&Breakfast</Board>
<Prices>
<Price Type="S" Currency="USD">
<TotalFixAmounts Gross="353.65" Nett="353.65">
<Service Amount="321.5"/>
<ServiceTaxes Included="true" Amount="32.15"/>
<Commissions Included="true" Amount="0"/>
<HandlingFees Included="true" Amount="0"/>
<Discount Amount="-0"/>
</TotalFixAmounts>
</Price>
</Prices>
<HotelRooms>
<HotelRoom Units="1" Source="1" AvailRooms="12">
<Name>Double Room</Name>
<RoomCategory Type="DBL">Double Standard</RoomCategory>
</HotelRoom>
<HotelRoom Units="1" Source="2" AvailRooms="11">
<Name>Double Room</Name>
<RoomCategory Type="DBL">Double Standard</RoomCategory>
</HotelRoom>
</HotelRooms>
<AdditionalElements>
<HotelOffers>
<HotelOffer>
<Name>Basic Discount 10%</Name>
</HotelOffer>
</HotelOffers>
</AdditionalElements>
</HotelOption>
</HotelOptions>
</HotelResult>
</Results>
</AvailabilityRS>
</HotelAvailResponse>
</soap:Body>
</soap:Envelope>"
Und ich habe diese Linq für diese Reaktion ist wie folgt:
XNamespace ns = "http://schemas.xmlsoap.org/soap/envelope/";
var hotels = (from hotelData in data.Descendants(ns + "Envelope").Descendants(ns + "Body").Descendants("HotelAvailResponse").Descendants("HotelAvailResult").Descendants("Results").Descendants("HotelResult")
select new Hotel
{
Code = hotelData.Attribute("Code").Value,
JpCode =
hotelData.Attributes().Any(x => x.Name == "JPCode")
? hotelData.Attribute("JPCode").Value
: "",
DestinationZone =
hotelData.Attribute("DestinationZone") != null
? hotelData.Attribute("DestinationZone").Value
: string.Empty,
JpdCode = hotelData.Attribute("JPDCode").Value,
//HotelName = Convert.ToString(hotelData.Element("Item").Value),
//Rating = Convert.ToInt32(hotelData.Element("StarRating").Value),
HotelInfo = (from hi in hotelData.Descendants("HotelInfo")
select new HotelInfo
{
Name = hi.Element("Name").Value,
Description = hi.Element("Description").Value,
Image = (from img in hi.Descendants("Images") select new Imagez { Images = img.Element("Image").Value }).ToList(),
HotelCategory = hi.Element("Name").Value,
HotelType = hi.Element("Description").Value,
Address = hi.Element("Description").Value,
}
).ToList(),
HotelOptions = (from ho in hotelData.Descendants("HotelOptions")
select new HotelOptions()
{
HotelOption = ho.Element("HotelOption").Attribute("RatePlanCode").Value,
Board = ho.Element("Board").Attribute("Type").Value,
Prices = (from pr in ho.Descendants("Prices") select new Prices() { Price = pr.Element("Price").Value,
TotalFixAmounts = (from tfa in pr.Descendants("TotalFixAmounts") select new TotalFixAmounts()
{ Service = tfa.Element("Service").Attribute("Amount").Value,
ServiceTaxes = tfa.Element("ServiceTaxes").Attribute("Included").Value,
AmountServiceTaxes = tfa.Element("ServiceTaxes").Attribute("Amount").Value,
Commissions = tfa.Element("Commissions").Attribute("Included").Value,
AmountCommissions = tfa.Element("Commissions").Attribute("Amount").Value,
HandlingFees = tfa.Element("HandlingFees").Attribute("Included").Value,
AmountHandlingFees = tfa.Element("HandlingFees").Attribute("Amount").Value,
Discount = tfa.Element("Amount").Attribute("Included").Value,
}).ToList(),
}).ToList(),
}).ToList(),
}).ToList();
return hotels;
bekomme ich keine Fehler und weder jede Ausnahme, aber die Anzahl der zurückgegebenen Hotels ist 0. Ich bin ein Anfänger bei Linq. Jede Hilfe wird sehr geschätzt, und es war 7 Stunden geradeaus, ich suche nach Hilfe und versuche, es zu erledigen. Jetzt fühle ich die Sackgasse.
Vielen Dank im Voraus.