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

Re: New spec. Questions

From: Frank Boumphrey <bckman@ix.netcom.com>
Date: Thu, 23 Jul 1998 23:52:02 -0400
To: "Dom mailing list" <www-dom@w3.org>, "Mike Champion" <mcc@arbortext.com>
Message-ID: <01bdb6b6$6adfd900$1eaddccf@bckman.ix.netcom.com>
Thank you Mike for those examples it clears every thing up.

Frank

-----Original Message-----
From: Mike Champion <mcc@arbortext.com>
To: Dom mailing list <www-dom@w3.org>
Date: Thursday, July 23, 1998 11:33 PM
Subject: Re: New spec. Questions


>At 05:34 PM 7/23/98 -0400, Frank Boumphrey wrote:
>>>>appendChild takes a Node argument and not a string.  Could you try again
>>
>>Sure. Basically what I am asking is  , once you've created an object how
do
>>you insert it into the tree.
>>
>>I start with:
>>
>><xdoc>
>><greeting>Hello XML</greeting>
>></xdoc>
>>
>>I want to end up with
>>
>><xdoc>
>><greeting>Hello XML</greeting>
>><greeting>Hello DOM</greeting>
>></xdoc>
>>
>>I create an element greeting with
>>
>>        document.createElement(greeting)
>>
>>I create a text node with
>>
>>        document.createTextNode("Hello DOM")
>>
>>How do I insert them into my document tree? by append child? by
>>insertBefore?
>
>You would setup your tree as follows:
>
>Element greet1 = document.createElement("greeting");
>Text    hello1 = document.createTextNode("Hello XML")
>greet1.appendChild(hello1);
>
>Element greet2 = document.createElement("greeting");
>Text    hello2 = document.createTextNode("Hello DOM")
>greet2.insertBefore(hello2, null);  // Alternate way to append
>
>document.appendChild(greet1);
>document.appendChild(greet2);
>
>There are may ways to access the nodes in the tree, e.g.
>
>greet1 = document.firstChild;
>greet2 = document.lastChild;
>or
>greet2 = greet1.nextSibling;
>
>or
>
>Nodelist list = document.childNodes;
>greet1 = list.item(0);
>greet2 = list.item(1);
>
>Is this any clearer?
>
>
Received on Friday, 24 July 1998 18:51:54 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:45 GMT