[jdom-interest] creating & parsing files

Kenneth Ellefsen kellefsen at bergen.oilfield.slb.com
Thu Jun 12 01:20:45 PDT 2003


> To read a file i copy its contents in a List object.
> Then i use an Iterator object to iterate through the list.
>  
> while(iterator.hasNext()){
>    doc.getRootElement.getChildText("First");///here instead of specifying the "First" string i want to iterate through the list and retreive their values
> I tried get(i) in a for loop but no results
> }
>  
> This returns me the value of the child. The problem is that i keep on getting the same value for all child nodes, instead of the value of the next 
> child node.
>  

If I understand what you want, you should try something like this, I
haven't tried it or anything...

List datasets = doc.getRootElement().getContent(new
ElementFilter("DataSet"));

Iterator itr = datasets.iterator();

while(itr.hasNext()){
   Element dataset = (Element)itr.next();
   *put me somewhere* = dataset.getChildText("First");
}

-- 
Regards,
Kenneth





More information about the jdom-interest mailing list