title: How to get Node from XML without considering namespace name in Java?
body: <p>I am writing a java program in which I am parsing input xml file which looks like this:</p>
  
  <pre><code>...
  &lt;ems:DeterminationRequest&gt;
      &lt;ems:MessageInformation&gt;
         &lt;ns17:MessageID xmlns:ns17="http://www.calheers.ca.gov/EHITSAWSInterfaceCommonSchema"&gt;1000225404&lt;/ns17:MessageID&gt;
         &lt;ns17:MessageTimeStamp xmlns:ns17="http://www.calheers.ca.gov/EHITSAWSInterfaceCommonSchema"&gt;2015-07-28T01:17:04&lt;/ns17:MessageTimeStamp&gt;
         &lt;ns17:SendingSystem xmlns:ns17="http://www.calheers.ca.gov/EHITSAWSInterfaceCommonSchema"&gt;CH&lt;/ns17:SendingSystem&gt;
         &lt;ns17:ReceivingSystem xmlns:ns17="http://www.calheers.ca.gov/EHITSAWSInterfaceCommonSchema"&gt;LD&lt;/ns17:ReceivingSystem&gt;
         &lt;ns17:ServicingFipsCountyCode xmlns:ns17="http://www.calheers.ca.gov/EHITSAWSInterfaceCommonSchema"&gt;037&lt;/ns17:ServicingFipsCountyCode&gt;
      &lt;/ems:MessageInformation&gt;
  &lt;/ems:DeterminationRequest&gt;
  ...
  </code></pre>
  
  <p>Now I am trying to get node "ems:MessageInformation" without considering namespace name "ems". So I tried following lines of code:</p>
  
  <pre><code>Document doc = db.parse(new FileInputStream(new File("D:\\test.xml")));
  Node element = doc.getDocumentElement().getElementsByTagNameNS("*","MessageInformation").item(0);
  System.out.println(element.getNodeName());
  </code></pre>
  
  <p>But it's giving Null Pointer exception because function is not reading required node. I gone through this <a href="http://docs.oracle.com/javase/6/docs/api/org/w3c/dom/Element.html#getElementsByTagNameNS%28java.lang.String,%20java.lang.String%29" rel="nofollow">link</a> for reference. Can someone tell me what I am doing wrong here?</p>