adding elements and attributes.

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

        document.createElement(farewell,name_attribute_list)

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
element.

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
null.i.e

document.createElement(farewell)

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


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