Populating list values using xstream

cybex

New Member
I am working with \[code\]Xstream\[/code\] to read some xml in the following format\[code\] <Objects> <Object Type="System.Management.Automation.Internal.Host.InternalHost"> <Property Name="Name" Type="System.String">ConsoleHost</Property> <Property Name="Version" Type="System.Version">2.0</Property> <Property Name="InstanceId" Type="System.Guid">7e2156</Property> </Object> </Objects> \[/code\]Basically under Objects tag there can be n number of Object Type and each Object Type can have n number of Property tags. So I have modelled by Java classes and the code to read it as follows\[code\] @XStreamAlias("Objects")class ParentResponseObject { @XStreamImplicit List <ResponseObject>responseObjects = new ArrayList<ResponseObject>(); public String toString () { return responseObjects.get(0).toString(); } }@XStreamAlias("Object")@XStreamConverter(value = http://stackoverflow.com/questions/12702753/ToAttributedValueConverter.class, strings = {"value" })class ResponseObject { @XStreamAsAttribute String Type; String value; @XStreamImplicit List <Properties> properties = new ArrayList<Properties>(); public String toString () { return Type+" value is "+"List is "+properties+ value; } }@XStreamAlias("Property")@XStreamConverter(value = http://stackoverflow.com/questions/12702753/ToAttributedValueConverter.class, strings = {"value" })class Properties { @XStreamAsAttribute String Name; @XStreamAsAttribute String Type; String value; Properties (String name, String type,String value) { this.Name = name; this.Type = type; this.value = http://stackoverflow.com/questions/12702753/value; } }\[/code\]Using this code, I am able to populate the \[code\]responseObjects\[/code\] List in the \[code\]ParentResponseObject\[/code\] class. However, the properties List in the \[code\]ResponseObject\[/code\] is always \[code\]null\[/code\] and is not getting populated , even though I am using the same technique in both the cases. I have debugged a lot but could not find anything. Your help and guidance is solicited.
 
Back
Top