I'm trying to retrieve the original XML for a row as a string from a multi row data set.
I'm using jQuery (just upgraded to 1.6.1 to see if this fixed the issue without success) and since using ie9 the result I get from the below code personsArray[pid] = $(this).xml;
is 'undefined'. Is there a workaround for this at 开发者_如何学Call. Any help would be appreciated, Many Thanks.
$(XMLdata).find('PersonRow').each(function(){
var pid = $(this).find('PersonId').text();
myData[i] = {
id: $(this).find('PersonId').text(),
name: $(this).find('Name').text(),
dob: $(this).find('BirthDate').text(),
address: $(this).find('MainAddress').text(),
telNo: $(this).find('MainTelNumber').text()
};
personsArray[pid] = $(this).xml;
i++;
});
Try this...
personsArray[pid] = $(this).xml2;
(function($){
$.fn.xml2 = function(){
//alert ("TEST");
if (window.XMLSerializer) // Internet Explorer 9 and Gecko
{
//alert ("MSIE 9, Gecko, XML FINDER");
var s="";
if (this.length)
(((typeof all!='undefined')&&all)?this:jQuery(this[0]).contents()).each(function(){
s+=(new window.XMLSerializer()).serializeToString(this);
});
return s;
} else {
if (window.DOMParser)
{
// Internet Explorer 8
//alert ("MSIE 8, XML FINDER");
var s="";
if (this.length)
(((typeof all!='undefined')&&all)?this:jQuery(this[0]).contents()).each(function(){
s+=window.ActiveXObject?this.xml:(new XMLSerializer()).serializeToString(this);
});
return s;
}
else // Internet Explorer OLD
{
// Internet Explorer 8 and below
//alert ("MSIE OLDER, XML FINDER");
var s="";
if (this.length)
(((typeof all!='undefined')&&all)?this:jQuery(this[0]).contents()).each(function(){
s+=window.ActiveXObject?this.xml:(new XMLSerializer()).serializeToString(this);
});
return s;
}
}
};
})(jQuery);
Best of luck.
精彩评论