I am parsing an xml file after a ajax call to 'get' the xml file. I am trying to return one of the nodes (using the find method). however it will not return the value in ie - fine in firefox. i am doing a alert to test the value and it just comes back blank. Below is the code:
function autoFeedGetter () {
$('#notifyBox').empty();
$.ajax ({
type: "GET",
url: "actual url removed",
datatype: "xml",
success: checkNoteDate
});
};
// get time date saved to fullDateTime Variable
funct开发者_JAVA百科ion checkNoteDate (xml) {
var noteDate = 'Not';
var lastSplit = 'Not';
// get published date from feed
noteDate = $(xml).find('entry published:eq(0)').text();
alert(noteDate);
}
The problem seems to be with this method - noteDate = $(xml).find('entry published:eq(0)').text();
however i have tried various other versions of this including: noteDate = $(xml).find('entry:first published').text();
if any one has any info will be most appreciated.
example xml
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:ibmfs="http://purl.org/net/ibmfeedsvc/feedsvc/1.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<title>Notifications</title>
<link rel="alternate" href="http://www.#.com/notifyme" />
<subtitle>This feed has been created using ROME (Java syndication utilities)</subtitle>
<entry>
<title>This is another test message !</title>
<link rel="alternate" href="http://#/cwweb/" />
<author>
<name>ContentWatch</name>
</author>
<updated>2010-02-12T14:22:19Z</updated>
<published>2010-02-12T14:22:19Z</published>
<dc:creator>ContentWatch</dc:creator>
<dc:date>2010-02-12T14:22:19Z</dc:date>
</entry>
<entry>
<title>You got mail!</title>
<link rel="alternate" href="http://#/cwweb/" />
<author>
<name>ContentWatch</name>
</author>
<updated>2010-02-10T12:11:49Z</updated>
<published>2010-02-10T12:11:49Z</published>
<dc:creator>ContentWatch</dc:creator>
<dc:date>2010-02-10T12:11:49Z</dc:date>
</entry>
</feed>
sensitive data removed - i am able to successfully parse the data in full but not retrieve one element - e.g. i am looking for the first published date
Looking at andrea varnier's reply at the bottom of http://groups.google.com/group/jquery-en/browse_thread/thread/adb2b047f3761179?pli=1, it would appear that IE doesn't work with xml files loaded up from your local machine. There is also a solution postage there if you don't want to rely on it just working when you deploy your page:
success: function(xmlData){
var data;
if ( typeof xmlData == 'string') {
data = new ActiveXObject( 'Microsoft.XMLDOM');
data.async = false;
data.loadXML( xmlData);
} else {
data = xmlData;
}
So it looks like IE has left the XML as a single string, so that method loads it up into an xml document object. You can then use jQuery on that object.
精彩评论