XML:
<data_format>
<data_length>15</data_length> <!-- -1 for unknown -->
<start_charater>$</start_charater>
<end_character1>B</end_character1>
<end_character2>E</end_character2>
<no_of_parameter>2</no_of_parameter>
<parameter>
<start_charater>A</start_charater>
<data_name>Azimuth</data_name>
<data_type>char</data_type>
<size>5</size>
</parameter>
<parameter>
<start_charater>R</start_charater>
<data_name>Range</data_name>
<data_type>char</data_type>
<size>5</size>
</parameter>
</data_format>
How should I convert this information encoded in XML into a class which can contain this structure? I need this to be done at runtime. I am getting the data for Azimuth and Range from a packet received through some port and need a structure to hold that data which I don't want to hard code but want to produce it at runtime when in parse that XML. the purpose for doing this is to increase the generic nature of my application.
Example :
<!-- for this xml -->
<data>
<data_member name="name" type="String"></data_member>
<data_member name="id" type="int"></data_member>
</data>
And the Java class that i want is:
class Data
{
private String name;
private int id;
public String getName()
{
return name;
}
public void setName(name)
{
this.name=name;
}
public int getId()
{
return id;
}
public void setId(id)
{
this.id=id;
}
}