On Thursday, February 6, 2003, at 11:08 AM, James Strachan wrote:
I don't quite follow your second suggestion but I think it assumes a ListSorry, the first line should be
containing all elements anywhere in the tree? In the document you describe
the doc.content() will be a list of one element (<root>)
/* this would be the equivalent of slowly using DocumentFactory.createElement() to create "foo" and then "bar" */
Element whatever = DocumentHelper.makeElement("foo/bar");
and the last line should be
parent.content().add(pos, whatever);
Hope that it makes sense now, Han Ming
----- Original Message ----- From: "Han Ming Ong" <[EMAIL PROTECTED]> To: "James Strachan" <[EMAIL PROTECTED]> Cc: "Dom4j-User" <[EMAIL PROTECTED]> Sent: Thursday, February 06, 2003 6:49 PM Subject: Re: [dom4j-user] Create Document...On Thursday, February 6, 2003, at 12:59 AM, James Strachan wrote:There's a helper method available for this. Document doc = DocumentHelper.createDocument(); Element page1 = DocumentHelper.makeElement("/root/pages/page1");Sorry for the nitpick but I suppose you meant Element page1 = DocumentHelper.makeElement(doc, "/root/pages/page1"); right? It would be super cool if you can do something like the following though: Element page1 = DocumentHelper.makeElement("/root/pages/page1"); Element parent = ... int pos = ... // get pos from convoluted algorithm somewhere parent.content().add(pos, page1); In this case, I can still use XPath to create element and have the liberty to insert it anywhere. Thanks for the good work, Han Ming
------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user