Hello,
I'm using dom4j to construct an XML document from a series of records. I need to be able to start searching the document at a particular place as I'm loading in the various elements. Once found, I need to be able to create a new element at that location. I've set up a series of records like so:
ELEMENT TEXT
library.book "Miles Copperthwaith"
library.book.chapter "I Am Born"
The algorithm:
Starting from an empty document, create the root element.
Set the context at the root
Cycle thru the elements, searching for the element starting at the current context.
If not found, create the element AT THAT POINT IN THE CONTEXT.
If found, set the context to that element and look for the next element, unless you are at the last element, in which case
you create the element at that point, the current context, and add the text.
It's simple, but you get the idea. How to set the current context, and create an element at the right place, using the current context?