enter code here
I've to deserialize this XML:
<rows profile="color">
<head>
<columns>
<column width="0" align="left" type="ro" sort="str" color=""><![CDATA[#]]></column>
<column width="80" align="left" type="ro" sort="str" color=""><![CDATA[Targa]]></column>
<column width="100" align="left" type="ro" sort="str" color=""><![CDATA[Telaio]]></column>
<column width="150" align="left" type="ro" sort="str" color=""><![CDATA[Tipo]]></column>
<column width="70" align="left" type="ro" sort="str" color=""><![CDATA[Archivio]]></column>
<column width="220" align="left" type="co" sort="str" color=""><![CDATA[Commenti]]><option value="A">A</option><option value="B">B</option><option value="C">C</option></column>
<column width="180" align="left" type="ed" sort="str" color=""><![CDATA[Destinatario]]></column>
</columns>
</head>
<row>
<cell><![CDATA[775]]></cell>
<cell><![CDATA[AA000AA]]></cell>
<cell><![CDATA[RTGGSHHJSJSNN]]></cell>
<cell><![CDATA[CDP]]></cell>
<cell><![CDATA[18]]></cell>
<cell><![CDATA[...]]></cell>
<cell><![CDATA[Â ]]></cell>
</row>
</rows>
But I haven't a defined class, how can I do it? I would use xstream library, but I don't know how use it.
EDIT:
But if I want to create a destination class, how I create it? I should have something like:
public class Rows {
private Head head;
private Row[] row;
}
public class Head {
private Columns columns;
}
public class Columns {
private Column column; // How can I get attributes?
}
public class Row {
private String [] cell;
}
and how can I use xstream after?
Take a look on JAXB. ( http://jaxb.java.net/ )
It's a great lib for read/write a XML into/from classes. I know there are some plugins for it. I'm almost sure you can generate/create classes from a XML file or create the XML from annotaded classes.
Some examples: http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/1.6/tutorial/doc/JAXBUsing3.html
Hello World: http://jaxb.java.net/tutorial/section_1_3-Hello-World.html