title: DOM XML Parser Example
body: <p>I have this XML file.I just parse this XML file.This example shows how to get the node by “name”, and display the value.How to show all records from database?</p>
  
  <pre><code>&lt;data399173_eff_sor&gt;
  &lt;record&gt;
      &lt;ID&gt;1&lt;/ID&gt;
      &lt;item_no&gt;1.0&lt;/item_no&gt;
      &lt;description&gt;Hack off tiles and make good walls&lt;/description&gt;
      &lt;price&gt;100&lt;/price&gt;
      &lt;base_qty&gt;50&lt;/base_qty&gt;
      &lt;var_qty&gt;20&lt;/var_qty&gt;
      &lt;base_price_&gt;5000&lt;/base_price_&gt;   
  &lt;/record&gt;
  &lt;record&gt;
      &lt;ID&gt;1&lt;/ID&gt;
      &lt;item_no&gt;1.03&lt;/item_no&gt;
      &lt;description&gt;Test&lt;/description&gt;
      &lt;price&gt;45&lt;/price&gt;
      &lt;base_qty&gt;100&lt;/base_qty&gt;
      &lt;var_qty&gt;4500&lt;/var_qty&gt;
      &lt;base_price_&gt;0&lt;/base_price_&gt;
  &lt;/record&gt;
  &lt;/data399173_eff_sor&gt;
  </code></pre>
  
  <p>and so on </p>
  
  <p>Java code </p>
  
  <pre><code>   File fXmlFile = new File("D:/formdata.xml");
      DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
      Document doc = dBuilder.parse(fXmlFile);
  
      doc.getDocumentElement().normalize();
  
      System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
  
      NodeList nList = doc.getElementsByTagName("record");
  
      System.out.println("----------------------------");
  
      for (int temp = 0; temp &lt; nList.getLength(); temp++) {
  
          Node nNode = nList.item(temp);
  
          System.out.println("\nCurrent Element :" + nNode.getNodeName());
  
          if (nNode.getNodeType() == Node.ELEMENT_NODE) {
  
              Element eElement = (Element) nNode;
  
              System.out.println("Item No : " + eElement.getElementsByTagName("item_no").item(0).getTextContent());
              System.out.println("Description : " + eElement.getElementsByTagName("description").item(0).getTextContent());
              System.out.println("price : " + eElement.getElementsByTagName("price").item(0).getTextContent());
              System.out.println("base qty : " + eElement.getElementsByTagName("base_qty").item(0).getTextContent());
              System.out.println("Var qty : " + eElement.getElementsByTagName("var_qty").item(0).getTextContent());
              System.out.println("Base price : " + eElement.getElementsByTagName("base_price_").item(0).getTextContent());                
  
          }
  </code></pre>
  
  <p>In this its just show first record.i want to display all records in the data base</p>