-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XMLSerializer and namespaces? #97
Comments
I have also ran into this issue. Below are my tests: "Without prefix" : function(test)
{
var xmldom = require('xmldom');
var di = new (xmldom.DOMImplementation)();
var doc = di.createDocument();
var element = doc.createElementNS('urn:test', 'test');
// namespace must be declared explicitly
element.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'urn:test');
doc.appendChild(element);
var xs = new (xmldom.XMLSerializer)();
var docAsString = xs.serializeToString(doc);
test.equal('<test xmlns="urn:test"/>', docAsString);
test.done();
},
"With Prefix" : function(test)
{
var xmldom = require('xmldom');
var di = new (xmldom.DOMImplementation)();
var doc = di.createDocument();
var element = doc.createElementNS('urn:test', 't:test');
// namespace must be declared explicitly
element.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:t', 'urn:test');
doc.appendChild(element);
var xs = new (xmldom.XMLSerializer)();
var docAsString = xs.serializeToString(doc);
test.equal('<t:test xmlns:t="urn:test"/>', docAsString);
test.done();
} If Similar tests work in browser environments, |
duplicate of #45 |
same here.. xmldom don't output the namespace when a child node is serialized. |
tyrasd
referenced
this issue
in tyrasd/jxon
Jan 13, 2016
Work around: var el = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
el.setAttribute('xmlns', 'http://www.w3.org/2000/svg'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there.
Not entirely sure this is an issue, really, but does anyone know how to get the XMLSerializer to output namespace information?
Say, code like this:
Gives this doc:
But, toString() outputs:
"<hest:foo/>"
not what I would expect:
"<hest:foo xmlns:hest="http://www.example.org/" />"
Does anyone know is this is a bug, me using xmldom wrong, or?
The text was updated successfully, but these errors were encountered: