title: Using JAXB to extract inner text of XML element
body: <h2>Problem</h2>
  
  <p>Given the following XML configuration file:</p>
  
  <pre><code>&lt;main&gt;
    &lt;name&gt;JET&lt;/name&gt;
    &lt;maxInstances&gt;5&lt;/maxInstances&gt;
    &lt;parameters&gt;
      &lt;a&gt;1&lt;/a&gt;
      &lt;b&gt;
        &lt;b1&gt;test1&lt;/b1&gt;
        &lt;b2&gt;test2&lt;/b2&gt;
      &lt;/b&gt;
    &lt;/parameters&gt;
  &lt;/main&gt;
  </code></pre>
  
  <p>I need to extract the value of the name and maxInstances elements and then the whole inner text of the parameters element. e.g.</p>
  
  <pre><code>name = "JET"
  maxInstances = 5
  parameters = "&lt;a&gt;1&lt;/a&gt;&lt;b&gt;&lt;b1&gt;test1&lt;/b1&gt;&lt;b2&gt;test2&lt;/b2&gt;&lt;/b&gt;"
  </code></pre>
  
  <p>Ultimately the parameters block can contain any well formed XML.</p>
  
  <h2>Attempted Solution</h2>
  
  <p>The following code works for name and maxInstances but not parameters:</p>
  
  <pre><code>@XmlRootElement(name="main")
  public class Main {
  
      @XmlElement(name="name", required="true")
      private String name;
  
      @XmlElement(name="maxInstances", required="true")
      private Integer maxInstances;
  
      @XmlElement(name="parameters")
      private String parameters;
  
  }
  </code></pre>
  
  <p>I've tried looking at solutions based on the following ideas but can't find something appropriate.</p>
  
  <p>Is there a different type I can use for the parameters object representing the XML Tree that I could parse to produce a string? e.g.</p>
  
  <pre><code>@XmlElement(name="parameters")
  private XmlNodeObject parametersNode;
  
  public String getParameters() {
      // Collapse node to single line of text
      return innerText;
  }
  </code></pre>
  
  <p>Or do I need to use some different kind of annotation?</p>
  
  <pre><code>@XmlSpecialAnnotation(...)
  @XmlElement(name="parameters")
  private String parameters;
  </code></pre>
  
  <p>Do I need to switch to a different style of parser?  Is it a good/bad idea to use two styles of parser?</p>