BAD MSG:
u can do is to create a new DOM and copy the required attributes (etcetra)
ith changed values..

Regards,
Ankur

-----Original Message-----
From: longinus [mailto:[EMAIL PROTECTED]
Sent: Friday, November 09, 2001 4:42 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: changing attribute value of the node


I want to change the value of the first child in the document.
I do it this way but it doesn't work.

Node n=doc.getFirstChild();
Element el=(Element)n;
el.setAttribute("data","dsgsdgdf");
theFormDOM.getDOM().replaceChild((Node)el,n);

Note that that first child may already have the data attribute. It
doesn't work, exception is generated.

Second try:

Node n=doc.getFirstChild();
Attr data=(theFormDOM.getDOM()).createAttribute("data");
data.setValue("no co jest?");
if(n.hasAttributes())
   ((Element)n).removeAttribute("data");

((Element)n).setAttributeNode(data);

The same result.
        
How can I modify the value of the attribute ?

Reply via email to