Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8127093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:24:06+00:00 2026-06-06T07:24:06+00:00

I have an XML feed that I’ve retrieved via httpwebrequest, and I’m having problems

  • 0

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 url
http://webservices.nextbus.com/service/publicXMLFeed?command=routeConfig&a=sf-muni&r=N

which I’ve stored in

 XDocument doc = XDocument.Parse(feedString);

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:

<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"/>

And so on and so on

I’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:

 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;


        }

How would I loop through each stop with that code above?

Thanks

EDIT: #2

This loop works, but keeps showing the first row of stop attributes:

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();
           }

I feel like I’m so close to figuring it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:24:08+00:00Added an answer on June 6, 2026 at 7:24 am

    Here is something you can use:

    XmlReader xmlReader = XmlReader.Create("http://webservices.nextbus.com/service/publicXMLFeed?   command=routeConfig&a=sf-muni&r=N");
    List<string> aTitle= new List<string>();
    
    // Add as many as attributes you have in your "stop" element
    
    while (xmlReader.Read())
    {
     //keep reading until we see your element
     if (xmlReader.Name.Equals("stop") && (xmlReader.NodeType == XmlNodeType.Element))
     {
       string title = xmlReader.GetAttribute("title");
       aTitle.Add(title);
    
       // Add code for all other attribute you would want to store in list.
      }
    }
    

    Finally call the list and based on index you can get all the items.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML feed that im pulling via javascript and translating it into
I have an xml feed that I have to check periodically for updates. The
I have a client that sends an xml feed which I parse using the
I have a class which parse an XML feed. In that class I have
I have an XML feed that looks something like this: I can parse the
Many times my client ask me whether they will deliver data via XML feed
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have built a site that relies on an XML feed that I currently
I have a XML feed of products that I break down into smaller XML
I have a tableView that loads an XML feed as follows: - (void)viewDidAppear:(BOOL)animated {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.