Hello everyone,
I am using SAX to parse some XML. Let's say I have the following XML document:
<queue>
<element A> 1 </element A>
<element B> 2 </element B>
</queue>
<queue>
<element A> 1 </element A>
<element B> 2 </element B>
</queue>
<queue>
<element A> 1 </element A>
<element B> 2 </element B>
</queue>
And I also have an Elements class:
public static Elements {
String element;
public Elements() {
}
public void setElement(String element){
this.element = element;
}
public String getElement(){
return element;
}
}
I am looking to write a ContentHandler that follows the following algorithm:
Vector v;
for every <queue> root node {
Element element = new Element();
for every <element> child node{
element.setElement(value of current element);
}
v.addElement(element);
}
So, I want to create a bunch of Element objects and add each to a vector...with each Element object containing its own String values (from the child nodes found within the root nodes.
I know how to parse out the elements and all of those details, but can someone show me a sample of how to structure my ContentHandler to allow for the above algorithm?
Thanks!