i trying unmarshal data of xml. if xml structure structure given below how made class print both values of attribute element. want unmarshal , consider vehicle 1 class , accessory class , accessory made attribute vehicle class. want class structure object, after unmarshalling used both values "wind screen" , "my wind screen broken".
<vehicle> <accessory type="wind screen">my wind screen broken</accessory> </vehicle>
as per xml, accessory
cannot attribute
element
vehicle
.
with below class, can unmarshall vehicle
object , retrieve values accessory
class. or can overrride tostring()
method of vehicle class
print values of accessory attribute type
, content
.
vehicle.class
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "vehicle", proporder = { }) public class vehicle { @xmlelement(name = "accessory") protected accessory accessory; // other elements }
accessory.class
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "accessory", proporder = { "value" }) public class accessory { @xmlvalue protected string value; @xmlattribute(name = "type") @xmlschematype(name = "anysimpletype") protected string type; // getters , setters ommitted brevity. }
Comments
Post a Comment