Re: XML attributes

On Thu, 20 May 1999 03:28:38 -0700 (PDT), BENOIT CAMREDON
(tioneb3279@yahoo.fr) wrote:
> I begin to learn XML and DOM. I would like to know, how can I modifie
> the attribute "name" in this programm :
> 
> # <story>
> # <page name="Hello">
> # <\page>
> # <\story>
> 
> I want to modifie this attribute in JavaScript. The document beyond is
> contained in a frame which is called by an other XML files (a XUL file).

The frames bit is the hard part, because (I think) frames aren't very
well specified in DOM Level 1.  And the fact that it's XML complicates
things further.

Thus the part I'm not sure about is how to get a variable holding the
object for the element.  That also depends on the context.  You could
use document.getElementsByName or some other method.  It would help
to see the context around the piece of XML you provide.

Once you have a variable holding the object for the page element
(called, say, pageElem), you could do:

nameAttr = pageElem.getAttributeNode("name");
pageElem.value = "your new value goes here";

If this is a question about the XUL being used in Mozilla, it might be
better to ask this question in one of the Mozilla groups to get a
better answer for the part I don't know.

David

Received on Friday, 21 May 1999 17:35:53 UTC