Java, Digester: order of processing the XML nested branches



I want to process an XML file where the entries are nested.



Digester d = new Digester();
d.setValidating(false);
d.push(new Object() {
public void addMessage(final String id, final String text) {
System.out.writeln ("Message");
}

public void addObject(final String className, final String index) {
System.out.writeln ("Object");
}
});


the XML:



<message id="id">
<object className="sdsdf" index="2234"></object>
</message>

<message id="id2" text="sdfsdfsdfsdf">
<object className="1" index="1"></object>
<object className="2" index="12"></object>
<object className="3" index="13"></object>
</message>


this will process it with the following order:



object
message
object
object
object
message


but I want it in linear



message
object
message
object
object
object


because I want to build a real tree, so first message must come, then its objects


No comments:

Post a Comment