Hi,

> I thought the .html() function does not work on XML documents. Your example
> does not work either.

That is true, but there seems to be no other simple way do transfer some 
content from one document to another with IE. You really need to copy the 
nodes to get that:

jQuery.fn.copyAppend = function(nodes) {
  var self = this;
  var doc = this.ownerDocument;
  $(nodes).each(function() {
        self.append(jQuery.cloneNewdoc.apply(this,[doc]));
  }
}

jQuery.cloneNewdoc = function(doc) {
  var tmp;
  switch( this.nodeType ) {
    case 1: // an element
      tmp = doc.createElement(this.nodeName);
      for( var i = 0; i < this.attributes; i++ ) 
        tmp.setAttributeNode(jQuery.cloneNewdoc.apply(this.attributes[i],
[doc]);
      for( var i = 0; i < this.childNodes; i++ ) 
        tmp.setAttributeNode(jQuery.cloneNewdoc.apply(this.childNodes[i],
[doc]);
      return tmp;
      break;
    case 2: // an attribute
      tmp = doc.createAttribute(this.nodeName);
      tmp.nodeValue = this.nodeValue;
      return this;
      break;
    case 3: // a text
      return doc.createTextNode(this.nodeValue);
      break;
  }
}

You will need to extend that if you whant to use CDATA sections, entities, 
etc. as well.

> Besides that you mixed up "content" and "bar" for the 
> each loop ;-)

Err, yes, sorry.

Christof

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to