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

  • Home
  • SEARCH
  • 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 8715421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:50:25+00:00 2026-06-13T05:50:25+00:00

Considering the following XML: <Stations> <Station> <Code>HT</Code> <Type>123</Type> <Names> <Short>H’bosch</Short> <Middle>Den Bosch</Middle> <Long>’s-Hertogenbosch</Long> </Names>

  • 0

Considering the following XML:

<Stations>
 <Station>
  <Code>HT</Code>
  <Type>123</Type>
  <Names>
    <Short>H'bosch</Short>
    <Middle>Den Bosch</Middle>
    <Long>'s-Hertogenbosch</Long>
  </Names>
  <Country>NL</Country>
</Station>
</Stations>

There are multiple nodes. I need the value of each node.
I’ve got the XML from a webpage (http://webservices.ns.nl/ns-api-stations-v2)

Login (–) Pass (–)

Currently i take the XML as a string and parse it to a XDocument.

var xml = XDocument.Parse(xmlString);
foreach (var e in xml.Elements("Long"))
{
   var stationName = e.ToString();
}
  • 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-13T05:50:27+00:00Added an answer on June 13, 2026 at 5:50 am

    You can retrieve “Station” nodes using XPath, then get each subsequent child node using more XPath. This example isn’t using Linq, which it looks like you possibly are trying to do from your question, but here it is:

    XmlDocument xml = new XmlDocument();
    xml.Load(xmlStream);
    XmlNodeList stations = xml.SelectNodes("//Station");
    
    foreach (XmlNode station in stations)
    {
        var code = station.SelectSingleNode("Code").InnerXml;
        var type = station.SelectSingleNode("Type").InnerXml;
        var longName = station.SelectSingleNode("Names/Long").InnerXml;
        var blah = "you should get the point by now";
    }
    

    NOTE: If your xmlStream variable is a String, rather than a Stream, use xml.LoadXml(xmlStream); for line 2, instead of xml.Load(xmlStream). If this is the case, I would also encourage you to name your variable to be more accurately descriptive of the object you’re working with (aka. xmlString).

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

Sidebar

Related Questions

Considering the following c code: typedef struct ELE *tree_ptr struct ELE { long val;
Considering following code public class A { public static void main(String[] args) { new
quick question on GWT from a newbie. Considering the following code: FlowPanel block =
Considering this article Developing a MVC component for Joomla , following is the code
considering the following code: models.py class Manufacturers(models.Model): name = models.CharField(max_length=32) class Cars(models.Model): producedby =
Considering the following code public interface IEntity { int Id { get; set; }
Considering the following code: <div style=float: left;> <select style=width: 160px;> <option>asd flkjh asdfkljha sdlkfjhasldjkfh
Considering following code: class Results { public int playerId; public int score; public int
Considering the following record types: type drCode1Body = {DrCode : byte ; Name :
Considering the following data frames : > tail(tot.final) names.id sequence names.reads width.reads names.counts st

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.