Further problem:
var xml_ns_regex = /xmlns:([\S]+)="([\S]+)"/ig;
This doesn't handle 'whatever', only "whatever".
Should probably grow up and use XPath!
From a comment in the source:
if a document redefines a namespace prefix for a subsection of the document, the
last declaration probably wins for the entire document
That's somewhat sad.