I am using jquery to pull in a XML feed. The problem is that all the information comes in under a single node:
<description><![CDATA[<div class="element element-date first">
Friday, 09 August 2013</div>
<div class="element element-textarea">
<p>CES MMA Champion Mike "The Beast" Campbell (13-4, Providence, RI.), Dinis "Sweetbread" Paiva (E. Providence, RI.), Keith "Sonic Boom" Jeffrey (9-2, Pawtucket, RI.) and more!</p></div>
<div class="element element-link last">
<a href="http://www.ticketmaster.com/ces-mma-presents-live-cagefighting-lincoln-rhode-island-08-09-2013/event/01004ACBB23C9DC4?artistid=1765605&majorcatid=10004&minorcatid=830" title="Click here to buy tickets!" target="_blank" >Click here to buy tickets!</a></div>]]></description>
I can pull this information in and get it to display just fine. What I need to do is pull a very specific part of this node, The date:
<div class="element element-date first">
Friday, 09 August 2013</div>
I am not sure on how to get this information so I will post the jquery code I am working on and see if anyone can help me figure out a solution:
$(document).ready(function () {
var i = 0;
var title = [];
var temp = [];
var desc = [];
var $divElements = $('.element element-date first');
$.ajax({
type: "GET",
url: "http://twinriver.com/index.php/entertainment/twin-river-event-center/feed/rss/events/event-center?format=feed",
dataType: "xml",
success: function (xml) {
$(xml).find('item').each(function () {
title[i] = $(this).find('title').text();
desc[i] = $(this).find('description').text();
i++;
//alert(i);
});
//this is where im trying to get it to pull the info i need.
for (var x = 0; x < i; x++) {
alert($(desc[x]).find($divElements).val());
}
for (var t = 0; t < i; t++) {
//
$('#EventList').append('<span class="title">' + title[t] + '</span>' + '<br />' + '<br />' + '<span>' + desc[t] + '<br />' + '<hr />');
}
}
});
});
Update 07/03/2013:
Been trying to use the solutions presented by the replies with no luck. The alert comes up with one of two items, its blank or reads "undefined". I have also tried using something like the following:
eDate[i] = $(this).find('description').find('.element.element-date.first').html();
alert(eDate[i]);
I added the var eDate = [];
with the rest of the declared variables
Could it cause a problem the fact that the info im trying to get is not wrapped in a
tag or ? If so is there anyway around having to add them? I dont think I can really edit the incoming data format but I will also research this as an option.