XMLResponse element show in list

Florentine3d

New Member
I'm doing a HttpWebrequest by using c#. I get the following response\[code\]<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Siri version="1.0" xmlns="http://www.siri.org.uk/"> <ServiceDelivery> <ResponseTimestamp>2013-03-21T11:40:13.514Z</ResponseTimestamp> <StopMonitoringDelivery version="1.0"> <ResponseTimestamp>2013-03-21T11:40:13.514Z</ResponseTimestamp> <RequestMessageRef>12345</RequestMessageRef> <MonitoredStopVisit> <RecordedAtTime>2013-03-21T11:40:13.514Z</RecordedAtTime> <MonitoringRef>020035811</MonitoringRef> <MonitoredVehicleJourney> <FramedVehicleJourneyRef> <DataFrameRef>-</DataFrameRef> <DatedVehicleJourneyRef>-</DatedVehicleJourneyRef> </FramedVehicleJourneyRef> <VehicleMode>bus</VehicleMode> <PublishedLineName>1</PublishedLineName> <DirectionName>Kempston</DirectionName> <OperatorRef>STB</OperatorRef> <MonitoredCall> <AimedDepartureTime>2013-03-21T11:41:00.000Z</AimedDepartureTime> <ExpectedDepartureTime>2013-03-21T11:44:27.000Z</ExpectedDepartureTime> </MonitoredCall> </MonitoredVehicleJourney> </MonitoredStopVisit> </StopMonitoringDelivery> </ServiceDelivery></Siri>\[/code\]This response is saved in a string variable called "ResponseFromServer"Now I just want to show the 'ExpectedDepartureTime' in a listboxI tried to do this with the following code:\[code\]//XMLResponse put in documentRoot XDocument documentRoot = XDocument.Parse(responseFromServer); //Linq To XML var documents = (from docs in documentRoot.Descendants("ServiceDelivery").Descendants("StopMonitoringDelivery").Descendants("MonitoredStopVisit").Descendants("MonitoredVehicleJourney").Descendants("MonitoredCall") select new { dep = docs.Element("ExpectedDepartureTime").Value }); //Show every ExpectedDepartureTime foreach (var i in documents) { lstHours.Items.Add(i); MessageBox.Show(i.ToString()); }\[/code\]When I try this nothing happens (the messagebox is not appearing and in the listbox i see nothnig). I also try to Descendant first the tag without success...Can anybody help me with this issue?Thanks!
 
Back
Top