Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Getting attributes from XML

12:23 am on Nov 4, 2014 (gmt 0)

New User from AU 

joined:Nov 4, 2014
posts: 1
votes: 0

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:


<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 '
World News Update, what you need to know&lt;a href = &quot;http://example.com/breaking-news-world/world-news-update-what-you-need-to-know-20141103-3jgd5.html&quot; target=&quot;_blank&quot; &gt;&quot;
Click to see story&quot;&lt;/a&gt;


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);

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

var objLastEvent = document.getElementById("<%= lastEvent.ClientID%>");
objLastEvent.value = items;



[edited by: Ocean10000 at 2:31 am (utc) on Nov 4, 2014]
[edit reason] Examplified [/edit]


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members