title: I want to change value of XML tag in java
body: <p>Here is my XML:</p>
  
  <pre><code>&lt;Connections&gt;
    &lt;Connection&gt;
      &lt;userName&gt;infadf&lt;/userName&gt;
      &lt;password&gt;tcslkvcvo@123&lt;/password&gt;
      &lt;schemaName&gt;dbo&lt;/schemaName&gt;
      &lt;status&gt;OLD&lt;/status&gt;
      &lt;portNum&gt;600687&lt;/portNum&gt;
      &lt;aliasName&gt;first&lt;/aliasName&gt;
    &lt;/Connection&gt;
  &lt;/Connections&gt;
  </code></pre>
  
  <p>I want to change value of tag "status" to "NEW".</p>
  
  <p>Below is my java code:</p>
  
  <pre><code>DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
              DocumentBuilder dBuilder = null;
  
                  try 
                  {
                      dBuilder = dbFactory.newDocumentBuilder();
                  } catch (ParserConfigurationException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
              if(new File(path).exists())
              {
                  Document doc = null;
                  try {
                      doc = dBuilder.parse(path);
                  } catch (SAXException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
              doc.getDocumentElement().normalize();
              NodeList nList = doc.getElementsByTagName("Connection");
  
              for (int temp = 0; temp &lt; nList.getLength(); temp++) 
              {
  
                      Node nNode = nList.item(temp);
                      Element eElement = (Element) nNode; 
                      if (nNode.getNodeType() == Node.ELEMENT_NODE) 
                      {
  
                      }
  
                      if(eElement.getElementsByTagName("status").item(0).getTextContent().equalsIgnoreCase("OLD"))
                      {
                          eElement.getElementsByTagName("status").item(0).setTextContent("NEW");
                      }
              }
  
          }
  </code></pre>
  
  <p>The value of status tag is not getting changed in XML.
  Please help.</p>