I have the following XML tag with many attributes. The number / name of the attributes is not specified, because I get XML at runtime, and I just know the tag name. How can I use JAXB to get the whole attribute as Map<String, String> ?
How can I add this to the following Java code:
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "script ") @XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.FIELD) public class SearchScriptElement { @XmlAttribute(name = "script") private String script = ""; public String getScript() { return name; } public void setScript(String name) { this.name = name; } }
XML example: I can have many attributes that are not known at runtime:
<ScriptList> <script name="xxx" value="sss" id=100 > <script> <script name="xxx" value="sss" id=100 alias="sss"> <script> </ScriptList>
source share