java - JAXB : Read non-static attributes into a collection -
i write jaxb implementation read/unmarshall below xml. challenge here how read attributes names not defined. in below example, keys can vary a1 an. question is, can use jaxb here? if yes, how write node.java class?
<?xml version="1.0"?> <node a1="blabla" a2="xyz" a3="application" a4="dfd" a5="dfd" ... > </node> public class node { //what done here? }
you can use @xmlanyattribute :
@xmlrootelement public class node { @xmlanyattribute private map<qname,string> attributemap; //getters , setters }
source : https://docs.oracle.com/javase/7/docs/api/javax/xml/bind/annotation/xmlanyattribute.html
Comments
Post a Comment