DOM4J allows you interact w/ your XML as java.lang.List objects. So, all you have to do is:
List bars = foo.elements( "bar" ); for( int a = 0, z = bars.size(); a < z; a++ ) { Element bar = (Element)bars.get( a ); List content = bar.content(); Node c = DocumentFactory.createElement( "C" ); c.setText( "c" ) content.add( 2, c ); } Dane Foster Equity Technology Group, Inc. http://www.equitytg.com 954.360.9800 ----- Original Message ----- From: "Robert W. Wade" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 04, 2003 20:33 Subject: [dom4j-user] Inserting an element at a precise location I am new to the dom4j API and am having trouble figuring out how to do something. The best way to describe what I want to do is through an example. A "before" and "after" snapshot of XML are shown below. Any help on how to do this is appreciated. Before: <foo> <bar> <A>a</A> <B>b</B> <D>d</D> </bar> ... [bar repeats many times, and I want to do the same for each bar] </foo> After: <foo> <bar> <A>a</A> <B>b</B> <C>c</C> <D>d</D> </bar> ... </foo> The main objective is to insert the <C> structure in a precise location of the <bar> structure. Thanks for your help, Rob __________________________________ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user