java - How to not show empty lists in JAXB XML marshalling? -


hi using jaxb (java) marshal xml.

i have xmllist elements size zero.

since constructs actual array list when getter called,

the output displays empty elements like

<aa></aa> 

is there anyway eliminate these "empty" elements?

thanks.

public void representingnullandemptycollections() throws exception {     jaxbcontext jc = jaxbcontext.newinstance(root.class);      root root = new root();      root.nullcollection = null;      root.emptycollection = new arraylist<string>();// shows empty element      root.populatedcollection = new arraylist<string>();     root.populatedcollection.add("foo");     root.populatedcollection.add("bar");      marshaller marshaller = jc.createmarshaller();     marshaller.setproperty(marshaller.jaxb_formatted_output, true);     marshaller.marshal(root, system.out); } 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -