I'm currently learning Java and how to deal with XML data. I've been learning how to use the Java SAX to parse my xml data to java objects.This XML document can change and have additional children added to it (For example: Birthday, height...). So what is the best recommendation to handle this XML document? I was told to use objects like this:
Object1.ID
Object1.Emp_Id
Object1.Emp_Name
...
Object2.ID
Object2.Emp_Id
Object2.Emp_Name
If the XML received a new child like Birthday, then the app will add it to the object as such:
Object1.ID
Object1.Emp_Id
Object1.Emp_Name
Object1.Birthday
Could someone point me to the right direction where I can dynamically create new objects like the example above that I can drop the child nodes into? So if the child nodes were to change, I don't have to directly specify it? Sorry for the noob talk, I'm not sure If I'm explaining this right. I'm learning SAX and found this tutorial, but doesn't seem to explain what I want to do: Mapping XML to Java Objects
Thank yoU!
XML file:
<?xml version = "1.0" ?>
<Employee-Detail>
<Employee>
<ID no="1">
<Emp_Id> E-001 </Emp_Id>
<Emp_Name> Vinod </Emp_Name>
<Emp_E-mail> [email protected] </Emp_E-mail>
<Sex>Male</Sex>
<Age>25</Age>
</ID>
</Employee>
<Employee>
<ID no="2">
<Emp_Id> E-002 </Emp_Id>
<Emp_Name> Amit </Emp_Name>
<Emp_E-mail> [email protected] </Emp_E-mail>
<Sex>Male</Sex>
<Age>21</Age>
</ID>
</Employee>
</Employee-Detail>