title: How to read and store XML data in database
body: <p>I am very new joiner in java and xml parser, I need to read data from an XMl file and store it in database.</p>
  
  <p>Firstly what I did is I have read data from an Xml fileand will store in in text file in Column and row format. Can any one please tell me how can read data from an xml file and manipulate data in form of column and rows.</p>
  
  <p>Column and rows means: </p>
  
  <ol>
  <li><p>The Node names must be displayed in header postion in row wise one after the other </p>
  
  <p>Example: </p>
  
  <pre><code>Column1, column2, column3.....
  </code></pre></li>
  <li><p>The values in that data must be stored in the above columns wise tags</p>
  
  <p>Example: </p>
  
  <pre><code>Column1, column2, column3,...  
  row1, row2, row3,...  
  row1, row2, row3,....  
  </code></pre></li>
  </ol>
  
  <p>Please help me, I am fight with this from past 10 days, I am unable to read data in column and row wise. What I have done is:</p>
  
  <p>Sample code:</p>
  
  <pre><code>  public class XMLReader extends XMLUtil{
  
      public static void main(String args[]) {
          try{
          XMLUtil xml=new XMLUtil();
          Document doc=xml.docFromFilePath("data/Schools.xml");
          //System.out.println("Root element :"+ doc.getDocumentElement().getNodeName());
          NodeList nl= doc.getElementsByTagName("*");
          for(int i=0;i&lt; nl.getLength();i++)
              {
                  /*String column1=nl.item(i).getNodeName();
                  String column=nl.item(i).getFirstChild().getNodeValue();
                  System.out.println(column1+":"+ column);*/
              Node n = nl.item(i);
              String name=n.getNodeName();
              System.out.print(name+ " ");
              }
          System.out.println();
  
  
  
  
           File f=new File("results/test1.txt");
          xml.prettyPrintToFile(f, doc);
          FileUtil futil=new FileUtil();
          futil.readFileBytes(f);
          //System.out.println(futil.toString());
          }
          catch(IOException e)
          {
              e.printStackTrace();
          }
  
      }
      }
  </code></pre>