[Simple-support] error while deserializing
Brought to you by:
niallg
|
From: Shobhit S. <sho...@gm...> - 2012-05-30 12:57:31
|
Hello everyone,
I am trying to deserialize the following xml
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<datadef>
<maxversion class="Action3" v.="3"/>
<maxversion class="Action4" v.="4"/>
<maxversion class="Action5" v.="5"/>
</datadef>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Using the following code :
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
@Root
public class maxversion {
@Attribute(name="class", required=false)
public String[] class1;
@Attribute(name="v.", required=false)
public int[] version;
}
import java.io.File;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class deserialize {
@ElementList(name="maxversion", required=false)
public maxversion max_version = new maxversion();
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Serializer serializer = new Persister();
File source = new File("file.xml");
deserialize deserialize = serializer.read(deserialize.class, source);
int count_max_version = deserialize.max_version.class1.length;
int i=0;
while(i<count_max_version)
{
System.out.println(deserialize.max_version.class1[i]);
System.out.println(deserialize.max_version.version[i]);
}
}
}
While executing class deserialize, I am getting following error :
Exception in thread "main"
org.simpleframework.xml.core.ElementException: Unable to determine
generic type for field 'max_version' public maxversion
deserialize.max_version
//followed by someother logs
I am not able to resolve the error. Can anyone help me out.
thanks in advance.
--
Shobhit Sharda
MSc in SSE
RWTH Aachen University
Aachen
Germany
blog: http://shobhitsharda.wordpress.com
|