From: "Minal Ashar" <[EMAIL PROTECTED]>
> Hi James,
>
>
> I am currently using your dom4j parser to parse my xml documents.I am
facing
> a slight difficulty in trying to achieve the following output.
>
>
> I have an xml file which conforms to a schema.I have an application which
is
> a frontend to view my xml and make additions to or delete from the xml
file.
>
> When I try to update my xml document with the new tag and its values,the
tag
> appends itself as the last child of its parent.
> My requirement is to position the tag within its parent so that it
validates
> against the schema.
>
> Would appreciate an insight into how would I do this using dom4j.
>
> Regards,
>
> Minal Ashar

Element.content() (and Element.elements())) returns a List which can be
manipulated directly using the standard List interface. Changes to the List
will be reflected in the document. So you could add an element, then move it
to the correct position. Or just create a new element then add it at the
correct index via List.set(int, node);

DocumentFactory factory = new DocumentFactory();
Element foo = ...;

Element bar = factory.createElement( "new" );
// add bar at a specific index
foo.content().add(2, bar);

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


-------------------------------------------------------
In remembrance
www.osdn.com/911/
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to