How to calculate distance between train/subway stations?

Anyone has a suggestion for a way to calculate distance between consecutive stations on a train/subway line?

I need something like this:

Station 1
5 km
Station 2
3 km
Station 3
etc

thanks beforehand for any hint

maybe you have to adapt some open-source routing solution which are listetd here, so that they can do a routing on railways?

http://wiki.openstreetmap.org/wiki/Routing

Thanks for the suggestion, but none of the routing services or tools seems to be designed for rail/subway - they seem to work for street shapes-based routing.

If there is a route you can sort the ways, split it up at a station and then calculate the distance by summing up the lenght of the ways.

And to find out the length of a way element in the OSM data look here:

http://help.openstreetmap.org/questions/469/where-can-i-see-the-length-of-a-certain-way-element-in-the-osm-data