代码之家  ›  专栏  ›  技术社区  ›  Stefan Kendall

IE将XML文档转换为字符串的解决方案?

  •  0
  • Stefan Kendall  · 技术社区  · 15 年前

    现在,我有以下内容:

    function jQueryToString( jQueryObject )
    {
       return $('<div>').append(jQueryObject.clone()).remove().html();
    }
    

    在Firefox、Opera、Chrome和Safari中可以很好地工作。但是,它在IE中中断了。我需要将XML文档对象转换为字符串,那么我的选项是什么?

    2 回复  |  直到 15 年前
        1
  •  0
  •   Stefan Kendall    15 年前

    对于IE,请执行以下操作:

    jQueryObject.each( function( e, elem ){
    $('#someDiv').append( elem.xml );
    } );
    
        2
  •  -1
  •   Russ Cam    15 年前

    免责声明:我没试过,但是怎么样

    function jQueryToString( jQueryObject )
    {
       var arr = $.map(jQueryObject, function(v) {
                     return $(this).html();
                 });
       return arr.join('');
    }