I've spent 2 days trying to figure this out and I'm afraid that it's something that's not possible. If that's the case then I'm thinking the wrong with with respect to OSM data.
Let's say I have a street, called Main Street. On the displayed map on openstreetmaps.org it looks like one road. To the underlying data it is made up of multiple ways (and is part of a relation of a larger route.)
Let's say I am only interested in the segment that passes through my town which is still made up of multiple ways.
Is there a (easy) way to find out what the ways are which make up this segment?
Is there a way to figure out ways that touch (either the beginning or end) of a way?
I can think of an expensive way (in terms of resources) doing this but I'm afraid that I'm looking at this the wrong way.
I was initially using a XML file that I downloaded of my town but I've also loaded the data into a postgre database (with postgis).
I've read a bunch of questions on stackexchange and the osm website as well. I've looked at this as well: http://wiki.openstreetmap.org/wiki/Elements