Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Objects>
- <Object Type="System.Tuning" >4456</Object>
- <Object Type="System.Lag" >7789</Object>
- </Objects>
- class ParentResponseObject {
- List <ResponseObject>responseObjects = new ArrayList<ResponseObject>();
- public ParentResponseObject() {
- // TODO Auto-generated constructor stub
- }
- }
- class ResponseObject {
- String Type;
- String Value;
- public ResponseObject() {
- }
- }
- XStream s = new XStream(new DomDriver());
- s.alias("Objects", src.core.PowerShell.MyAgain.ParentResponseObject.class);
- s.alias("Object", src.core.PowerShell.MyAgain.ResponseObject.class);
- s.useAttributeFor(src.core.PowerShell.MyAgain.ResponseObject.class, "Type");
- s.addImplicitCollection(src.core.PowerShell.MyAgain.ParentResponseObject.class, "responseObjects");
- ParentResponseObject gh =(ParentResponseObject)s.fromXML(k1);
- @XStreamAlias("Object")
- @XStreamConverter(value = ToAttributedValueConverter.class, strings = { "value" })
- public class ResponseObject {
- @XStreamAlias("Type")
- private String type;
- private String value;
- public ResponseObject() {
- }
- public String getType() {
- return type;
- }
- public String getValue() {
- return value;
- }
- }
- @XStreamAlias("Objects")
- public class ParentResponseObject {
- @XStreamImplicit
- private final List <ResponseObject> responseObjects = new ArrayList<ResponseObject>();
- public ParentResponseObject() {
- }
- public List<ResponseObject> getResponseObjects() {
- return responseObjects;
- }
- }
- XStream xStream = new XStream();
- xStream.processAnnotations(ParentResponseObject.class);
- ParentResponseObject parent = (ParentResponseObject)xStream.fromXML(file);
- for (ResponseObject o : parent.getResponseObjects()) {
- System.out.println(o.getType() + ":" + o.getValue());
- }
Add Comment
Please, Sign In to add comment