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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -