Chapter 13 — I Need to Get To... 263
FIGURE13-2: Showing a list of available routes and starting points.
Then the individual elements from the data are extracted. First, the base route information is
extracted. Although you extract all of the potential route elements, only one should be returned
at a time, so the information from the first element is used first:
var routeinfo = ;
xmlsource.documentElement.getElementsByTagName(“routeinfo”);
routeidfield.value = routeinfo[0].getAttribute(‘routeid’);
routetitle.value = routeinfo[0].getAttribute(‘title’);
routedescription.value = routeinfo[0].getAttribute(‘description’);
Then the distance information is extracted, which includes the distance in both kilometers and
miles:
var distanceinfo = ;
xmlsource.documentElement.getElementsByTagName(“distance”);
infopanel.innerHTML = ‘Distance: ‘ + distanceinfo[0].getAttribute(‘km’) +
‘ km, ‘ +
distanceinfo[0].getAttribute(‘miles’) + ‘ miles’;
After this the list of points is obtained, pushing each point onto an array. Because the points
are supplied in the correct sequence from the database backend, there is no requirement to sort
or order the points that are extracted. The order they are parsed from the document is the cor-
rect order for them to be generated onto the map.