java - XStream Element contains TextNode and Element -


i using xstream parse xml , goes while.... there situation xstream seem can't handle it.

there's 1 tag named "", in different xml file, can contain text node or other xml tag.

it can this:

xml file 1: <spec> text node here </spec>  xml file 2: <spec id="1">     <tag1>value</tag1>     <tag2>value</tag2> </spec> 

and in spec class, have code...

@xstreamalias("spec") @xstreamconverter(value = toattributedvalueconverter.class, strings = { "spec" })   //when text node public class spec {     string spec;        // text node      @xstreamalias("id")     @xstreamasattribute     string id;      @xstreamalias("tag1")     string tag1;      @xstreamalias("tag2")     string tag2;     // getter , setter... } 

in case of xml file 1, works fine, in case of xml file 2, values of fields "tag1" , "tag2" null, , value of field "spec" : "\n\t\t"

what can handle these 2 files? in advance!

yes i've solved problem... not in way.

split spec class 2 classes: 1 text node , other xml elements.

and while parsing different xml file, using xstream.alias("spec", spec1.class); , xstream.alias("spec", spec2.class); switch 2 different format.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -