title: XML Element with attribute and CDATA How to retrieve b both using JAXB in Eclipse
body: <p>A section element of XML includes an attribute and CDATA:</p>
  
  <pre><code>        ELEM: nodeName="ConfigData" local="ConfigData"
              ATTR: nodeName="ConfigSize" local="ConfigSize" nodeValue="356"
                TEXT: nodeName="#text" nodeValue="356"
            TEXT: nodeName="#text" nodeValue=[WS]
            ELEM: nodeName="Data" local="Data"
                ATTR: nodeName="Format" local="Format" nodeValue="L5K"
                  TEXT: nodeName="#text" nodeValue="L5K"
              TEXT: nodeName="#text" nodeValue=[WS]
              CDATA: nodeName="#cdata-section" nodeValue="[360,0,6,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"
              TEXT: nodeName="#text" nodeValue=[WS]
            TEXT: nodeName="#text" nodeValue=[WS]
          TEXT: nodeName="#text" nodeValue=[WS]
  </code></pre>
  
  <p>I have used the following code but it could not fetch the CDATA.
  @XmlRootElement(name="ConfigData")</p>
  
  <pre><code>public class ConfigData {
  
    private int configSize;
    private Data data;
  
    @XmlElement(name="Data")
    public void setData(Data data) {  
      this.data = data;  
    } 
    public Data getData() {
          return data;
      }
  }
  
  @XmlRootElement(name="Data")
  
  public class Data {
  
    private String format;
    private String cData;
  
    @XmlAttribute(name="Format")
      public void setFormat(String format) {
      this.format = format;
      }
    public String getFormat() {
          return format;
      }
  
    @XmlCDATA()
    @XmlJavaTypeAdapter(value=AdapterXmlCDATA.class)
    public void setCData(String cData) {  
      this.cData = cData;  
    }  
    public String getCData() {  
      return cData;  
    }  
  }
  
  public class AdapterXmlCDATA extends XmlAdapter&lt;String, String&gt; {
  
      @Override
      public String marshal(String value) throws Exception {
          return "&lt;![CDATA[" + value + "]]&gt;";
      }
      @Override
      public String unmarshal(String value) throws Exception {
        //System.out.println("AdapterXmlCDATA:" + value);
        return value;
      }
  }
  </code></pre>
  
  <p>I would appreciate if someone can tell me what I am doing wrong. I am thinking that if using a right CDATA notation in the Data Class like "@XmlCDATA()
      @XmlJavaTypeAdapter(value=AdapterXmlCDATA.class)" can make it work. Thanks</p>