W3C home > Mailing lists > Public > www-dom@w3.org > July to September 1998

adding elements and attributes.

From: Frank Boumphrey <bckman@ix.netcom.com>
Date: Thu, 9 Jul 1998 17:55:15 -0400
To: "Dom mailing list" <www-dom@w3.org>
Message-ID: <01bdab84$41910de0$a1addccf@bckman.ix.netcom.com>
If this has been discussed before I apologise, but I couldnt find any
reference to it.

I am a little confused as to how to add an attribute to a new element.when
to use "createAttribute()", and when to use "setAttribute().

suppose I wanted to create a new element

    <farewell manner="sad">Goodbye cruel world!</farewell>

 using my hypothetical user agent XOM.exe.

here is the code I write to create the element


but where do I get the name of the attribute list from, because
createAttributeList() takes no parameters, and I cant use

[elementname].createAttributeList() because I have not yet created the

So the only way I can think of to do this is to create an element without
any attributes in which case the WD tells me the attributes parameter can be


now I have the element name I can add to them by using
[element].setAttribute method.

So thats o.k but then what is createAttributeList, and createAttribute for?

Am I missing something obvious here? This paradox only became apparent to me
while trying to code for XOM.exe!!


Frank Boumphrey
XML and style sheet info at Http://www.hypermedic.com/style/index.htm
Author: - Professional Style Sheets for HTML and XML http://www.wrox.com
Received on Thursday, 9 July 1998 17:49:21 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:04 UTC