JAXB should ignore element
问题 The structure <html> <span><h1>test</h1></span> <table> </table> </html> How can i get the text "test" if <span> might be a <div> ? @XmlAccessorType(XmlAccessType.FIELD) public class HtmlTag { @XmlElement(name = "h1") String h1; } Unmarshalls to null. 回答1: @XmlAccessorType(XmlAccessType.FIELD) public class HtmlTag { @XmlAnyElement List<org.w3c.dom.Element> elements; } get test string HtmlTag htmlTag = //... Element firstElement = htmlTag.elements.get(0); // this is first element, // currently