XPath supports subscript operators so you can do things like Element element = (Element) doc.selectSingleNode( "foo/bar[2]" ); element.addElement( "xyz" );
James ----- Original Message ----- From: "Frank Sharpless" <[EMAIL PROTECTED]> To: "Dom4j List (E-mail)" <[EMAIL PROTECTED]> Sent: Thursday, February 14, 2002 8:56 PM Subject: [dom4j-user] Reading/writing multiple elements > Hello all, > > I really hope that this make sense!! :) > > How do you figure out where you are in the tree? If I want to write some XML > tags to a tree that contains the multiple elements how do I figure out what > element I want to write to? > > Example > > I want to write the following: > > <A1>one</A1> > <A2>two</A2> > > I want to write it to the SECOND /PHIMPORT/IMPORTINFORMATION/DETAIL/ > section: > > Start with this.. > > <PHIMPORT> > <IMPORTINFORMATION> > <DETAIL> > <INDEXKEY> > <A1>0</A1> > </INDEXKEY> > </DETAIL> > <DETAIL> > <INDEXKEY> > <A0>SDFK</A0> > </INDEXKEY> > </DETAIL> > </IMPORTINFORMATION> > </PHIMPORT> > > End up with this.... > > <PHIMPORT> > <IMPORTINFORMATION> > <DETAIL> > <INDEXKEY> > <A1>0</A1> > </INDEXKEY> > </DETAIL> > <DETAIL> > <INDEXKEY> > <A0>SDFK</A0> > <A1>one</A1> > <A2>two</A2> > </INDEXKEY> > </DETAIL> > </IMPORTINFORMATION> > </PHIMPORT> > > > Thanks for the help.... > > > A. Frank Sharpless > Manager, Application Development > Paperhost.Com, Inc. > [EMAIL PROTECTED] > 770.998.9172.611 > > > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user
