Instead of improving my other answer, I'd rather make a new one since I basically need to re-write it to work with how you want it and the old answer may help people for other reasons...
So, after extracting out the HTML-string from the XML you link to, you can go forth with it like this:
// First we'll extract out the parts of the HTML-string that we need.
var jq_html = $(html_from_xml);
var style = jq_html.find('head').find('style').html();
var style_string = style.toString();
var table_and_stuff = jq_html.find('body').html();
// If you want to place it into the existing page's DOM,
// we need to place it inside a new DIV with a known ID...
$('body').append('<div id="new_stuff"></div>');
$('#new_stuff').html(table_and_stuff);
// Now, we need to re-write the styles so that they only
// affect the content of the 'new_stuff' DIV:
styles_array = style_string.split('}');
var new_styles = '';
$.each(styles_array,function(i) {
if(i<(styles_array.length-1)) {
new_styles += "#new_stuff "+styles_array[i]+"}";
}
})
$('head').append('<style type="text/css">'+new_styles+'</style>');
And that should really do it. The trick is that CSS will choose the most specific style for the case. So, if you have a <td>
inside the "newstuff" div, it will get the style from the new stylesheet. If you have a <td>
outside of that "newstuff" div, it will get the old style.
I hope this solves your problem.