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

php - Webix Data Loading from Laravel Link -

libGdx unable to find files in android application data directory -

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