title: Reading an xml file in android
body: <p>I have saved the IP configuration of the server in a xml file in /Simulate/Configuration.xml in my android internal storage</p>
  
  <p>Configuration.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  
  &lt;IPconfig&gt;
  
  &lt;ipAddress&gt;172.**.***.***&lt;/ipAddress&gt;
  &lt;port&gt;5000&lt;/port&gt;
  
  &lt;/IPconfig&gt;
  </code></pre>
  
  <p>The code to access the ipaddress and port number</p>
  
  <pre><code>try {
  File sdcard = Environment.getExternalStorageDirectory ();
  File FXmlFile = new File (sdcard, "/ Simulate / Configuration.xml");
  DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
  DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
  Document doc = dBuilder.parse(fXmlFile);
  doc.getDocumentElement (). normalize ();
  NodeList nlist = doc.getElementsByTagName ("IPconfig");
  for (int temp = 0; temp &lt;nList.getLength (); temp + +) {
  Node nNode = nList.item(temp);
  if (nNode.getNodeType () == Node.ELEMENT_NODE) {
  Element eElement = (Element) nNode;
  SERVERIP= eElement.getAttribute("ipAddress");
  System.out.println ("server ip:" + SERVERIP);
  SERVERPORT= eElement.getAttribute("port");
  System.out.println ("Server port:" + ServerPort);
  }
  }
  }catch (Exception e) {
              e.printStackTrace();
              }
  </code></pre>
  
  <p>When I print SERVERIP and SERVERPORT both return a null. How can I get the ipaddress and port value from the xml? Any help is appreciated. Also if there is a better way to specify the ipconfig of server.</p>