users@jaxb.java.net

Re: simple Xml->Java example

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 14 May 2007 17:17:24 -0700

Senthil Rajasekharan wrote:
> I am trying to create a Java class that should
> generate the following Xml on "marshalling".
>
> <ElementA>
>
> <ElementB>stringValue</ElementB>
> <ElementC name="stringName">stringValue</ElementC>
> <ElementD>integerValue</ElementD>
>
> </ElementA>
>
> What is the corresponding Java representation with
> annotations?
>
> I have tried this a few times on my own...but I don't
> understand how to generate ElementC.

You'd need a class.

class ElementC {
   @XmlAttribute String name;
   @XmlValue String value;
}

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com