Hi Nani, I don't know if this is relevant, but cloneNode returns a copy with a parent value of null. Since nodes added to other node structures need to have the same parent, this might be your problem. Try using getOwnerDocument() to get the parent, then create a new element to append.
John > -----Original Message----- > From: Jayaram Narayana [mailto:[EMAIL PROTECTED] > Sent: mercredi, 27. mars 2002 11:11 > To: 'Xindice Dev. Group' > Subject: NullPointerException: appendChild() > > > hi! > > when i try to run this code against the xml given below i get > the following > exception: > > Has Children: true > Exception in thread "main" java.lang.NullPointerException > at > org.apache.xindice.xml.dom.ContainerNodeImpl.appendChild(Unkno > wn Source) > > the code fragment is: > : > : > Database database = (Database) c.newInstance(); > DatabaseManager.registerDatabase(database); > col = > DatabaseManager.getCollection("xmldb:xindice:///db/misc"); > XMLResource xmlResource = (XMLResource) > col.getResource("test"); > Node node = xmlResource.getContentAsDOM(); > System.out.println("Has Children: " + node.hasChildNodes()); > Node newNode = node.cloneNode(true); > node.appendChild(newNode); > : > : > > the xml file is: > > <?xml version="1.0"?> > <parent> > <child id="123">Text goes here</child> > </parent> > > i am not able to figure out what i am doing wrong. any help > will be greatly > appreciated. > > thanks in advance, > -nani > >
