First let me apologise. I have seen several solutions to problems very similar to mine but have been unable to apply them in my page. I am appalled by my ignorance!
I am trying to access the attributes in an XML file with data that looks like this extract:
<data>
<event id='e569'
start="Monday, 3 November 2014, 7:55:55 AM"
title="World News Update, what you need to know"
icon= '../Media/book.png '
image=""
>
World News Update, what you need to know<a href = "http://example.com/breaking-news-world/world-news-update-what-you-need-to-know-20141103-3jgd5.html" target="_blank" >"
Click to see story"</a>
</event>
</data>
The code I am using gives me the "event" information OK ("World News Update...").
How can I get the value of the attribute "start"?
My code so far:
function getLastEvent() {
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "DataXML/SMHFEED.XML", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML.documentElement;
var items = xmlDoc.getElementsByTagName('event').length; // Number of records on xml table
var x = xmlDoc.getElementsByTagName("event");
y = x[items-1].childNodes[0].nodeValue; // get last event record
alert(y)
var objLastEvent = document.getElementById("<%= lastEvent.ClientID%>");
objLastEvent.value = items;
}
TIA
ZermattMan
[edited by: Ocean10000 at 2:31 am (utc) on Nov 4, 2014]
[edit reason] Examplified [/edit]