Hi Richie
There are two things you need:
First, where a location has an "fd" (false destination), when you're showing trains at the "tpl" for that stop, you should show the destination as the value of the "fd".
For example, a West Kirkby - West KIrby West Kirby service via Liverpool Central will have a false destination of LIVRPLCL up until James Street, so you should display it as a "Liverpool Central" train up until James Street, but from Moorfields onwards, you should display it as a "West Kirby" train.
Second, the reference data contains a list of 'via' locations. For each "at" location identified by CRS code, you need to look at the "dest" location (TIPLOC) and see if the train goes via the "loc1" and optionally "loc2" TIPLOCs. If it does, then display the "viatext" - but only for the CRS code.
For example:
<Via at="CTR" dest="CHST" loc1="LVRPLSL" viatext="via Liverpool" />
At Chester (CTR), a train with a destination of CHST (Chester) and a TIPLOC of LIVRPLSL (Liverpool Lime Street - Low Level) after the "at" location and before the "dest" should be displayed as "via Liverpool".
Look for the false destination and then any 'via' location first, otherwise you may end up displaying a train as "Liverpool Central via Liverpool Central" if its false destination happens to be Liverpool Central!
Peter
OpenTrainTimes Ltd. registered in England and Wales, company no. 09504022.
Registered office: 13a Davenant Road, Upper Holloway, London N19 3NW