If you're interested in working with the order of a document's nodes, you should get the document's content via the content() method, and edit the returned List:
Document doc;
List content = doc.content();
int rootIdx = content.indexOf(doc.getRootElement());
content.add(rootIdx, DocumentFactory.createProcessingInstruction("target", " data "));
best, christian.
On Jul 16, 2004, at 2:02 PM, Yoel Spotts wrote:
I have noticed the following behavior:
If I create a document (with default DocumentFactory), add a Root Element and only then add a Processing Instruction, when I print out the xml document (using asXML()), the PI ends up at the end of the document. It appears that all children of the Document are stored as a list and and such the PI is stored after the root element. I wonder if maybe internally, the PI should be moved to the front of the list when on is added. I can see an argument that this is the reponsability of the developer to ensure that a PI is added before a root element. Am I correct that this is the expected behavior?
Thanks!
Yoel Spotts
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user