convert an XML jQuery Object to String

I have an uploaded xml file that I’m perusing using jQuery via var $ts = $.parseXML(filecontents)

I have attempted to convert back to the original source when locating objects within the XML Document by utilising:

  • Fast file hashing of large files
  • A selector switch id with jquery as condition
  • What hash algorithms are supported by modern Javascript?
  • Why crypto.createHash returns different output in new version?
  • is there any builtin javascript string hash function in newest browsers?
  • How can I replace a window's URL hash with another response?
  • $('<div>').append($ts.find('Object').clone()).html();
    

    In chrome, this works absolutely fine and I get the output as it looks in the original document. In firefox, it reorders the attributes of elements alphabetically.

    Since I’m hashing this output, I need it to be the same as the input. Is this possible to enforce at all, or am I better with a different method of walking through this xml document?

  • Immutable Hash and Array implementation in JavaScript?
  • jQuery retrieve hash and apply it as an ID
  • Preserving url hash over page change
  • How can I update window.location.hash without jumping the document?
  • is there any builtin javascript string hash function in newest browsers?
  • How to create Hash object/array using jquery?
  • One Solution collect form web for “convert an XML jQuery Object to String”

    Use the XMLSerializer API instead:

    var foo = $ts.find("Object").get(0);
    var serializer = new XMLSerializer(); 
    var original = serializer.serializeToString(foo);