You have to use the method createElementNS
, instead of createElement
, since the latter creates an element with empty namespace URI.
Chrome serializes incorrectly the document (if you parse the string you would get a different document, with namespace URIs wrong), Firefox does the job right. Actually a bug was filed and marked as solved, but the problem seems to be still there.
So, simply replace doc.createElement(yourElementName)
with doc.createElementNS('http://AOR-AppML.org', yourElementName)
.