OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] adding new attribute to an existing xml file usingJAXP wit

[ Lists Home | Date Index | Thread Index ]

Hi

When I wrote the line doc.appendChild(tagNode); after adding the 
attribute it generated the error:

----
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to 
insert a node where it is not permitted.
   at org.apache.xerces.dom.CoreDocumentImpl.insertBefore(Unknown Source)
   at org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source)
   at TestFile.addMIDs(TestFile.java:78)
   at TestFile.main(TestFile.java:115)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
----

Im obviously doing something wrong.

I used the logic that I first cast the Node to an Element and then 
access the Element methods to setAttribute(name,value). I then didnt 
know how to update the Element to the Document so simply appended it. I 
think Im doing something wrong here.

Thanks for helping out
Rahil








 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS