How to convert xml into Java Object which contain ArrayList through XStream Libray?



I want to convert the XML file to Java object which have array. Objective is to store the xml values into the array of the object. Suppose XML file as:



<test>
<Name> John</Nmae>
<age>19</age>
<phone>2225364</phone>
</test>


Now the Java Class is like:



public class TestArray
{
private List list = new ArrayList();
public display()
{
Iterator<String> itr = list.iterator();
while(itr.hasNext())
{
System.out.println(itr.next());
}
}
}


I want to parse the xml file to object so that I can retrieve the value of Name, Age and Phone from List. I'm new to the XStream, kindly help me out


No comments:

Post a Comment