Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

xmlns attribute in new node

6 views
Skip to first unread message

NONE

unread,
Nov 15, 2008, 7:13:53 PM11/15/08
to
hi
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 ?

thx

NONE

unread,
Nov 15, 2008, 7:15:43 PM11/15/08
to

NONE

unread,
Nov 15, 2008, 7:24:52 PM11/15/08
to
hi
i m working on a firefox extension that use xml documents but i have a

Martin Honnen

unread,
Nov 16, 2008, 7:55:26 AM11/16/08
to
NONE wrote:

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/

0 new messages