java - XML parser using jaxb -


how object of nested xml using jaxb. have following xml -

<?xml version="1.0" ?>     <file>     <markups>     <markup>         <author>author</author>         <name>3w2fg</name>         <source>mobile_ipad</source>         <createdon>2013-05-20t11:22:23</createdon>         <entities>             <entity>                 <entitywdth>209</entitywdth>                 <entitycolor>                     <red>127.5</red>                     <green>0</green>                     <blue>127.5</blue>                 </entitycolor>                 <entityfillcolor>                     <red>227.5</red>                     <green>0</green>                     <blue>327.5</blue>                 </entityfillcolor>                 <entityradian>0</entityradian>                 <entityendy>304</entityendy>                 <entitystx>438</entitystx>                 <entitytypecode>7</entitytypecode>                 <entitypageno>1</entitypageno>                 <entityht>183</entityht>                 <entitycenterx>542.5</entitycenterx>                 <entityname>rectangle</entityname>                 <entitysty>121</entitysty>                 <entityendx>647</entityendx>                 <entitycentery>212.5</entitycentery>             </entity>         </entities>     </markup> </markups> <name>7987ab12-4915-49e5-8bbd-f98d6054ef6b.jpg</name> <filename>img_0008.jpg</filename> </file> 

i using jaxb unmarshal under -

jaxbcontext jbcontext = jaxbcontext.newinstance(com.arc.markupinfo.generated.file.class); com.arc.markupinfo.generated.objectfactory factory = new    com.arc.markupinfo.generated.objectfactory(); com.arc.markupinfo.generated.file fileobj = factory.createfile(); unmarshaller unmarshaller = jbcontext.createunmarshaller(); fileobj = (com.arc.markupinfo.generated.file) unmarshaller.unmarshal(new   file(xmllocation)); fileobj.getfilename(); 

the object created values except entitycolor.red ... , entityfillcolor.red.... these values come 0,0,0 while xml shows has proper values

entitycolor.red ... , entityfillcolor.red ... have type int (integer).
use double (double), float (float) or string colors in color object.

@xmlaccessortype(xmlaccesstype.field) public class entity  {    //...    private color entitycolor;    private color entityfillcolor;    //... }    @xmlaccessortype(xmlaccesstype.field) public class color  {    private double red;   // or float, or string    private double green; // or float, or string    private double blue;  // or float, or string }   

also can unmarshal example simplest way:

file file = javax.xml.bind.jaxb    .unmarshal(new java.io.file(xmllocation),file.class); 

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 -