title: How to modify xml node values using java? (Not by tag name)
body: <p>i'm trying to modify some parameters of a xml file from a java file. In all the posts i found people modify these parameters searching for it by tag name, but in my case it doesn't work.</p>
  
  <p>An example of my xml file is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;comp&gt;
      &lt;params&gt;
          &lt;param name="id"&gt;1&lt;/param&gt;
          &lt;param name="type"&gt;aaaa&lt;/param&gt;
          &lt;param name="bus"&gt;123&lt;/param&gt;
      &lt;/params&gt;
  &lt;/comp&gt;
  </code></pre>
  
  <p>How i can access the parameters by "name"?</p>
  
  <p>Finally my code in java is:</p>
  
  <pre><code>public void modifyXml(){
      String path = "C:\\Workspace\\Project\\data.xml";
      DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
      Document doc = docBuilder.parse(path);
      Node comp = doc.getFirstChild();
      Node params = doc.getElementsByTagName("params").item(0);
      loadParams(params);
  }
  
  private void loadParams(Node params) {
      NodeList list = params.getChildNodes();
      for (int i = 0; i &lt; list.getLength(); i++) {
          Node url =   list.item(i);
          String nodeName = url.getNodeName();
          NamedNodeMap attributes = url.getAttributes();
  
          //System.out.println(attributes.item(i));
          if (nodeName.equalsIgnoreCase("param") &amp;&amp; url.getFirstChild()!=null) {
              ServerProperties.getExternalParamsMap().put(attributes.getNamedItem("name").getNodeValue(), url.getFirstChild().getNodeValue());
              System.out.println((String) url.getFirstChild().getNodeName());
              System.out.println(url.getFirstChild().getNodeValue());
           }
      }
  }
  </code></pre>
  
  <p>It prints me the node's values but not the parameter name. Parameters name appear like: "#text"</p>
  
  <p>Thanks!</p>
  
  <p>Regards!!</p>
  
  <p>Eric P.</p>