dynamically read xml element and value in java
<p>I'm trying to read XML(whatever, i don't know it's structure, bcz i'm reading flie from server.), and i searched a lot on SO. but not found anything helpful.</p>

<p>1> i want to retrieve XML's node name, starting from root to end of file, child or child of child untill there's no child or sibling remaining.</p>

<p>2> in similar question, i found that they use tagname to retrieve value of that tag, so i want to pass that node name inside this to get value... </p>

<p>is it possible to do dynamically. or have to follow same structure as in previous questions like statically add tagname to retrieve value. </p>

<p>after doing this in java, i want to create executable jar, and want to use it in mirth.</p>

<hr>

<p><strong>EDIT</strong>
i want to find element and it's value such that, in first condition i'm looping my arraylist which i named <code>masterheader</code> which contain all tag name, and in second loop i'm going to find node name from xml, and and inside that two for loop i specified one condition, if both match, then it get node name and it store a value in , separated form, because i want to convert it in <code>csv</code>.</p>

<p>here, masterheader and childheader is <code>arraylist</code>. masterheader contain all header by default. and we gonna add nodename in <code>childheader</code>, nd if both match then we add value in result string.
for e.g. <code>masterheader = [employeename, employeesurname, fathername, mobile, salary]</code>
and in <code>childheader = [employeename, mobile, salary]</code> //this is based on xml parsing.</p>

<pre><code>for(i=0;i&lt;masterheader.size();i++)
{
    for(j=0;j&lt;childheader.size();j++)
    {
         if((masterheader[i]).equals(childheader[j]))
        {
           //get the value of that node, + ","        
        }
        else
         {
                count++
         }
    }
if(count==childheader.size()){
 //add into result string +null+","  
}
}
</code></pre>