NONE wrote:
> i m working ona firefow extension that use xml documents but i have a
> little trouble when i create a new node. All the new nodes created with
> createElement from a DOMParser have an empty xmlns="" . I can not remove
> this one or prevent this one from beeing added to the new node.
> Does someone have a solution or an explanation ?
Use the namespace aware DOM Level 2 methods like createElementNS e.g. to
create
<root xmlns="
http://example.com/2008/ns1"><foo><bar>baz</bar></foo></root>
with the DOM you need e.g.
const ns1 = '
http://example.com/2008/ns1';var doc = document.implementation.createDocument(ns1, 'root', null);
var foo = doc.createElementNS(ns1, 'foo');
var bar = doc.createElementNS(ns1, 'bar');
bar.textContent = 'baz';
foo.appendChild(bar);
doc.documentElement.appendChild(foo);
--
Martin Honnen
http://JavaScript.FAQTs.com/_______________________________________________
dev-tech-xml mailing list
dev-tech-xml@...
https://lists.mozilla.org/listinfo/dev-tech-xml