Christ. Sometimes it just takes someone to point out the obvious ... I was grabbing the root node of the document after creating it with createDocument(null,"root",null), assigning it to a Node object, but then later on, when trying to append my first element to the root, I was trying to append to the doc, not the root node I had retrieved.

Sorry for wasting everyone's time!!

Brice

Richard Rowell wrote:

On Fri, 2003-04-11 at 08:55, Brice Ruth wrote:



I create a 'Document' object from a DOMImplementation, then assign 'getDocumentElement()' to a Node object. So far, so good - no exceptions. I then create an Element from the Document object, using 'createElement' and set some attributes on the element before trying to append it to my 'root' Node, which I got from 'getDocumentElement()' previously. It is at this point, in the 'appendChild' call, that I get the exception HIERARCHY_REQUEST_ERR: This node isn't allowed here. What's going on here?



Are you sure you are not trying to create two root nodes? That would be invalid XML. THis is OK: Document doc= new DocumentImpl(); Element root = doc.createElement("person"); // Create Root Element Element item = doc.createElement("name"); // Create element root.appendChild( item ); // atach element to Root doc.appendChild( root ); // Add Root

This gives a Hierarchy request error:
Document doc= new DocumentImpl();
Element item = doc.createElement("person");
doc.appendChild( item ); Element item = doc.createElement("name");
doc.appendChild( item );






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to