[jdom-interest] converting Elements to objects
Gregory S. Hill
ghill at vmtllc.com
Thu Feb 17 11:42:31 PST 2005
It seems to me the easiest approach would be to make the objects
'xml-aware'. You would need to pass each item in the list to a
'factory' of some sort, which would identify the root element, and hand
the contents off to an object of that class-type. The object would then
use JDOM to crawl through the contents, handing the sub-attributes and
elements off to the various fields for population.
Actually, if there's an easier way to do this, I'm all ears. I've done
this in a quick-and-dirty way in the past, but am having to prep a
larger solution. If a more generalized way of doing this is possible,
I'd be interested, too.
Anton Stoyanov wrote:
> i have the following (seems common, but all the posts about that are
> from 2000 !)
> i have an xml file like so:
> and a Customer.java class which has
> String name;
> String tel;
> with JDOM I can get a java.util.List of elements, but how can I
> transform them into customer objects ?
> I'm very interested in finding a solution which is independant of the
> "customer" bit. because i have other classes too.
> thanks alot
> if you need more information, please tell me.
More information about the jdom-interest