Need help parsing XML feed in Windows Phone

aRGuVaN

New Member
I have an XML feed that I've retrieved via httpwebrequest, and I'm having problems parsing the feed since its unlike the times I've tried this in the past. So far I have the urlhttp://webservices.nextbus.com/service/publicXMLFeed?command=routeConfig&a=sf-muni&r=Nwhich I've stored in\[code\] XDocument doc = XDocument.Parse(feedString);\[/code\]And I know that when I've dumped that all in a listbox for debugging purposes, I get everything there, I'm just having problems parsing the feed:\[code\]<body copyright="All data copyright San Francisco Muni 2012."><route tag="N" title="N-Judah" color="003399" oppositeColor="ffffff" latMin="37.7601699" latMax="37.7932299" lonMin="-122.5092" lonMax="-122.38798"><stop tag="5240" title="King St & 4th St" lat="37.7760599" lon="-122.39436" stopId="15240"/><stop tag="5237" title="King St & 2nd St" lat="37.7796199" lon="-122.38982" stopId="15237"/><stop tag="7145" title="The Embarcadero & Brannan St" lat="37.7846299" lon="-122.38798" stopId="17145"/><stop tag="4510" title="Embarcadero Folsom St" lat="37.7907499" lon="-122.3898399" stopId="14510"/><stop tag="5629" title="Tunnel Entry Point Inbound Nea" lat="37.79279" lon="-122.39126" stopId="15629"/>\[/code\]And so on and so onI'd like to store each attribute in each stop tag into an array, but I'm completely stumped as to how I'd begin even. Thanks Update:I think I got it to work on that first msdn link, but this only gets the first line:\[code\] using (XmlReader reader = XmlReader.Create(new StringReader(feed))) { reader.ReadToFollowing("stop"); reader.MoveToFirstAttribute(); string tag = reader.Value; reader.MoveToNextAttribute(); string title = reader.Value; reader.MoveToNextAttribute(); string lat = reader.Value; reader.MoveToNextAttribute(); string lon = reader.Value; }\[/code\]How would I loop through each stop with that code above?ThanksEDIT: #2This loop works, but keeps showing the first row of stop attributes:\[code\]using (XmlReader reader = XmlReader.Create(new StringReader(feed))) { reader.ReadToFollowing("stop"); while (reader.MoveToNextAttribute()) { // Move the reader back to the element node. //reader.ReadToFollowing("stop"); reader.MoveToFirstAttribute(); string tag = reader.Value; MessageBox.Show(tag); reader.MoveToNextAttribute(); string title = reader.Value; MessageBox.Show(title); reader.MoveToNextAttribute(); string lat = reader.Value; MessageBox.Show(lat); reader.MoveToNextAttribute(); string lon = reader.Value; MessageBox.Show(lon); } reader.MoveToElement(); }\[/code\]I feel like I'm so close to figuring it out.
 
Back
Top