How can I replace one of the attributes in NamedNodeMap (DOM)?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Orna_Vel
Posted On:   Wednesday, September 26, 2001 10:08 AM


In the XML file I have the following:




All this attribues after parsing the document will go to some NamedNodeMap.

Now I can reach them by getNamedItem(String) function, but how can I change one of them - the "number" for example?


If the answer is "remove all", "create new" and "add new", how can I create new? In that case I have an error:

"WRONG_DOCUMENT_ERR: That node doesn't belong in this document."
:-(


Thank's.

Re: How can I replace one of the attributes in NamedNodeMap (DOM)?

Posted By:   Bozidar_Dangubic  
Posted On:   Wednesday, September 26, 2001 11:01 AM

you are getting an error because you have to create nodes using the original Document object that created all the nodes in the Document you are modifying. At times, to get things working I had to pass the Document object around in order to overcome this limitation (in my opinion it is a limitation). Element elem1 = doc.createElement("animal") creates element that can be appended to doc, but Element elem2 = doc2.createElement("animal") creates an element that cannot be appended to doc but only to doc2. that you have to always be aware of.
About | Sitemap | Contact