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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -