I've tryed what you described, but the Jquery .html() function ignores the lowercase node characters. I needed something to parse an XML to a String in a case sensitive way, so I've developed next plugin my own. Copy next code to a file and save as a .js file.
/*
* THIS COMES WITH ABSOLUTELY NO WARRANTY.
*
* This JQuery plugin just provides an easy way to parse an XML document object
* into a case sensitive string.
* Self closing is not detected, and will be stringifyed as an empty xml node.
*
* Tested in the following browsers:
* -Chrome (v 33.0.1750.154 m)
* -IE9 (v 9.0.8112.16421)
* -Firefox (v 28.0)
* -Opera (v 12.16)
* -Safari (v 5.1.7 (7534.57.2))
*
* @author Germán Coines Laguna - german.coines@hotmail.com
*
* @usage $.fn.xmlToString(xmlObj)
* @param xmlObj - An XML document object
* @returns The Xml stringifyed.
*
* @version 1.0
* @depends JQuery v.1.9.1
*/
(function($){
$.fn.xmltostring = function(xml)
{
var xmlText = "";
$(xml).children().each(function(i,node){
stringifyNode(node);
});
function stringifyNode(nd)
{
//obtain analisys obj
var az = analyzeNode(nd);
xmlText += "<" + az.nm + " " + az.ats + ">";
if(az.chd) $(nd).children().each(function(i, ch){
stringifyNode(ch);
});
xmlText += "</" + az.nm + ">";
}
function analyzeNode(nodeObj)
{
var obj = {nm: "", ats:"", chd: false, txt: ""};
//Name
obj.nm = nodeObj.nodeName;
//Attributes
$(nodeObj.attributes).each(function(i, at){
obj.ats += at.name + "=\"" + at.value + "\" ";
});
//Children
obj.chd = $(nodeObj).children().length > 0;
//Text
obj.txt = $(nodeObj).text();
return obj;
}
return xmlText;
};
}(jQuery));
I haven't tested timmings for such huge XML files, but It did what I've required.
Hope It helps.
Here's an example on how to use it (Note you have to register the JQuery .js file, the file you saved with the code above, and replacing "yourPathToFile/yourFileName.xml" by your required values):
<script type="text/javascript" >
$(document).ready(function(){
var xml = loadXMLDoc("yourPathToFile/yourFileName.xml");
alert($.fn.iwebxmltostring(xml));
//var test = $.parseXML($("#result").text());
//alert($(test).children().prop('nodeName'));
});
</script>
Good bye!