You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Craig Burlock <cr...@gmail.com> on 2012/08/26 05:28:13 UTC
Trying to find a nice XML Bean with generic put functionality
Hello everyone!
Does anyone know of a bean / object with a "put" method that is designed to
be XMLizable using the key name and it's value object?
Something like this:
*BeanObject root = new BeanObject();
beanObject.put("name", "Joe Smith");
beanObject.put("gender", "Male");
beanObject.put("age", 22);*
...will produce this xml:
*<root>
<name>Joe Smith</name>
<gender>Male</gender>
<age>22</age>
</root>*
I'm certain I've used a Java Object that does this may moons ago.
The standard Java Map kinda works, but it produces excessive nodes and the
node names aren't based on the key.
I am wanting something generic because I would like to avoid creating new
classes just so my xml is clean...
Can anyone help me find the Object I am looking for (or is this my version
of Skittle-Brew)?
Re: Trying to find a nice XML Bean with generic put functionality
Posted by Jacob Danner <ja...@gmail.com>.
I can't say I've needed xmlbeans for this, but I've used free marker
templates to do something similar based on map key/values.
Would that work for you?
-jacobd
On Aug 25, 2012 8:29 PM, "Craig Burlock" <cr...@gmail.com> wrote:
> Hello everyone!
>
> Does anyone know of a bean / object with a "put" method that is designed
> to be XMLizable using the key name and it's value object?
>
> Something like this:
>
> *BeanObject root = new BeanObject();
> beanObject.put("name", "Joe Smith");
> beanObject.put("gender", "Male");
> beanObject.put("age", 22);*
>
> ...will produce this xml:
>
> *<root>
> <name>Joe Smith</name>
> <gender>Male</gender>
> <age>22</age>
> </root>*
>
> I'm certain I've used a Java Object that does this may moons ago.
>
> The standard Java Map kinda works, but it produces excessive nodes and the
> node names aren't based on the key.
>
> I am wanting something generic because I would like to avoid creating new
> classes just so my xml is clean...
>
> Can anyone help me find the Object I am looking for (or is this my version
> of Skittle-Brew)?
>
>
>