(function($) {

$.fn.xml = function () {return $.xml(this[0])}
$.xml = function(xml) { // dump the xml back to html text 
    if (!xml) return "" 
    var res = "" 
    var tag = xml.nodeName 
    var showTheTag = tag.charAt(0) != "#" 
    if (showTheTag) res += '<' + tag 
    if (xml.attributes) {
        var attrs = xml.attributes 
        for (var i = 0; i < attrs.length; i++){ 
            var attr=attrs[i] 
            if (attr.specified) res +=' ' + attr.name + '="' + attr.value + 
'"' 
        } 
    } 
    if (showTheTag) res+= ">" 
    if (xml.nodeType == 8){ 
        res += "<!-- " + xml.nodeValue + " -->" 
    } else if (xml.nodeValue != null){ 
        res +=  xml.nodeValue.replace(/\&/g,"&amp;").replace(/\</g,"&lt;") 
    } 
    if (xml.hasChildNodes()) { 
        var children = xml.childNodes 
        for (var i = 0; i < children.length; i++){ 
            var child = children[i] 
            res += $.xml(child) 
        } 
    } 
    if (showTheTag)  res += '</' + tag + '>' 
    return res 
}

})(jQuery);
