document.getElementByTagName XML



I have a handler which returns me a XML Request as an alert() with the following



<?xml version="1.0" encoding="UTF-8"?>
<gml:TimePeriod xmlns:gml="http://ift.tt/WaETtx">
<gml:beginPosition>2011-10-18T15:15:00.000+02:00</gml:beginPosition>
<gml:endPosition>2014-11-23T14:45:00.000+01:00</gml:endPosition>
</gml:TimePeriod>


The hander looks like that:



function handler(request) {
alert(request.responseText);
};


Now I would like parse the xml tag “beginPosition” to an array. I used the following code within the handler:



function handler(request) {
alert(request.responseText);
var xmlDoc = request.responseXML;

timeArray = xmlDoc.getElementByTagName('beginPosition').value= new Date(request.responseText).toTimeString();
console.log(timeArray);
};

var timeArray;
alert(timeArray);


Finally I got the error message: TypeError: xmlDoc.getElementByTagName is not a function


How can I parse the date value in that array from the xml request?


No comments:

Post a Comment