3 Replies Latest reply: Jul 18, 2011 10:46 AM by 716599 RSS

    JAXB mapping of field to sub nodes

    872760
      I have the following XML I consume:

      <root>
           <node1>
                <node2 expirationDate="10/10/2012" />
           </node1>
      </root>

      And the following Java class:

      @XmlRootElement(name= "root")
      class Foo
      {
      private String expirationDate;
      }

      My question is whether it is possible to map the expirationDate field member DIRECTLY to a <node2> value/attribute. Perhaps something like:

      @XmlAttribute(name="node1/node2/expirationDate")

      Currently, the only way I can think about doing it is by having another class I'll map for node1 and another class for node2 and have the first class have a field member of the second class.