Using JAXB to extract inner text of XML element
You can use the @XmlAnyElement annotation as described by bmargulies. To map to the object model in your question you can leverage a DOMHandler. Main import javax.xml.bind.annotation.*; @XmlRootElement(name=”main”) @XmlAccessorType(XmlAccessType.FIELD) public class Main { private String name; private Integer maxInstances; @XmlAnyElement(value=ParameterHandler.class) private String parameters; } ParameterHandler import java.io.*; import javax.xml.bind.ValidationEventHandler; import javax.xml.bind.annotation.DomHandler; import javax.xml.transform.Source; import javax.xml.transform.stream.*; … Read more