title: How to read an XML element programmatically in Java?
body: <p>I am working on how to read xml file in java.Below is my xml code</p>
  
  <pre><code>&lt;path&gt;
      &lt;Excelpath&gt;
          C:/Documents and Settings/saalam/Desktop/Excel sheets/New Microsoft Excel Worksheet (3).xls
      &lt;/Excelpath&gt;
  &lt;/path&gt;
  </code></pre>
  
  <p>Using this, I wrote java code to read this xml, below is my java code</p>
  
  <pre><code>try {
      //Using factory get an instance of document builder
      DocumentBuilder db = dbf.newDocumentBuilder();
  
      //parse using builder to get DOM representation of the XML file
      Document doc = db.parse(fXmlFile);
      //read the xml node element
      doc.getDocumentElement().normalize();
      System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
      System.out.println("expath is:"+doc.getElementsByTagName("Excelpath"));
  } catch(ParserConfigurationException pce) {
      pce.printStackTrace();
  } catch(SAXException se) {
      se.printStackTrace();
  } catch(IOException ioe) {
      ioe.printStackTrace();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>here what i want to achieve is,i need to read the xml from xml i need to get the excelpath which i  provided.later on i need to use this excelpath and use this to get the excelsheet values for my further code. when i tried to run the following code,it didnt give me option to run it as java application rather it displayed "run configuration". is this correct that its appearing as "run configuration" and not as "run as java application".</p>