Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically create java objects for each XML child node?
    primarykey
    data
    text
    <p>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:</p> <pre><code>Object1.ID Object1.Emp_Id Object1.Emp_Name ... Object2.ID Object2.Emp_Id Object2.Emp_Name </code></pre> <p>If the XML received a new child like Birthday, then the app will add it to the object as such:</p> <pre><code>Object1.ID Object1.Emp_Id Object1.Emp_Name Object1.Birthday </code></pre> <p>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: <a href="http://www.javaworld.com/javaworld/jw-08-2000/jw-0804-sax.html?page=1" rel="nofollow">Mapping XML to Java Objects</a></p> <p>Thank yoU!</p> <p>XML file:</p> <pre><code>&lt;?xml version = "1.0" ?&gt; &lt;Employee-Detail&gt; &lt;Employee&gt; &lt;ID no="1"&gt; &lt;Emp_Id&gt; E-001 &lt;/Emp_Id&gt; &lt;Emp_Name&gt; Vinod &lt;/Emp_Name&gt; &lt;Emp_E-mail&gt; Vinod1@yahoo.com &lt;/Emp_E-mail&gt; &lt;Sex&gt;Male&lt;/Sex&gt; &lt;Age&gt;25&lt;/Age&gt; &lt;/ID&gt; &lt;/Employee&gt; &lt;Employee&gt; &lt;ID no="2"&gt; &lt;Emp_Id&gt; E-002 &lt;/Emp_Id&gt; &lt;Emp_Name&gt; Amit &lt;/Emp_Name&gt; &lt;Emp_E-mail&gt; Amit2@yahoo.com &lt;/Emp_E-mail&gt; &lt;Sex&gt;Male&lt;/Sex&gt; &lt;Age&gt;21&lt;/Age&gt; &lt;/ID&gt; &lt;/Employee&gt; &lt;/Employee-Detail&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload