title: How can I convert object (JAXB) or byte[] (from this object) to `org.w3c.dom.Element`?
body: <p>I have Java class (JAXB) for example:</p>
  
  <pre><code>Test test = new Test();
  test.set....
  //fill test object
  ............
  </code></pre>
  
  <p>Now I need convert this object to <code>org.w3c.dom.Element</code></p>
  
  <p>Now I have converter for converte to <code>byte[]</code>:</p>
  
  <pre><code>public &lt;T&gt; byte[] marshal(T value) {
      try {
        StringWriter sw = new StringWriter();
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(value,sw);
        return sw.toString().getBytes();
      } catch (JAXBException e) {
        throw new RuntimeException(e.getMessage());
      }
    }
  </code></pre>
  
  <p>And My question: How can I convert <code>test</code>  or <code>byte[]</code> to <code>to org.w3c.dom.Element</code>?</p>
  
  <p>EDIT:</p>
  
  <p>answer the question in the commentary why I need it</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlAnyElement;
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlType;
  import org.w3c.dom.Element;
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {
      "any"
  })
  @XmlRootElement(name = "MessagePrimaryContent")
  public class MessagePrimaryContent {
  
      @XmlAnyElement
      protected Element any;
  
  
      public Element getAny() {
          return any;
      }
  
  
      public void setAny(Element value) {
          this.any = value;
      }
  
  }
  </code></pre>
  
  <p>I need set My object to <code>setAny</code> method. Such protocol and format. I did not invent it</p>