我解析一个XML文件后,ajax调用'获取'的XML文件。我试图返回其中一个节点(使用find方法)。但它不会返回IE中的值 - 在Firefox中罚款。我正在做一个警报来测试这个值,它只是回到空白。下面是代码:jQuery解析xml不返回数据在ie
function autoFeedGetter() {
$('#notifyBox').empty();
$.ajax ({
type: "GET",
url: "actual url removed",
datatype: "xml",
success: checkNoteDate
});
};
// get time date saved to fullDateTime Variable
function checkNoteDate (xml) {
var noteDate = 'Not';
var lastSplit = 'Not';
// get published date from feed
noteDate = $(xml).find('entry published:eq(0)').text();
alert(noteDate);
}
的问题似乎是用这种方法 - 这包括noteDate = $(xml).find('entry published:eq(0)').text();
但是我已经尝试了各种其它版本: noteDate = $(XML).find(“条目:首次发布')。text();
如果有任何人有任何信息将不胜感激。
示例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>
敏感数据中去除 - 我能够成功地解析在充分的数据,但不能检索一个元件 - 例如我正在寻找第一个发布的日期
你能举一个你正在下载的xml的例子吗? –
可能只是一个拼写错误,但'.ajax()'的'datatype'选项应该是'dataType',而不是'datatype'。 –
Cheers Crescent Fresh确实发现了一个错字:-) – jonnyhitek