Hey all,
I'm teaching myself XML while doing some freelance work, and have run into a problem. I'm pulling in an external .xml file and trying to pull just the date, but the XML has a pretty complex nomenclature for the date.
Code:
<pubDate>
<![CDATA[ Tue, 27 Dec 2011 13:46:09 EST ]]>
</pubDate>
I'm pulling this into my page using:
Code:
<script type="text/javascript">
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","/rss.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("item");
for (i=0;i<x.length;i++)
{
document.write(x[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue);
}
document.write("</table>");
</script>
How do I make the script pull just the date? So instead of:
"Tue, 27 Dec 2011 13:46:09 EST"
it would should up as simply:
"December 27"
Thanks for the help in advance.