title: Parsing attribute in XML with DOM parser
body: <p>I am currently parsing XML, but im not quite sure how to parse the "status" attribute of "message":</p>
  
  <pre><code>&lt;message status="test"&gt; &lt;text&gt;sometext&lt;/text&gt; &lt;msisdn&gt;stuff&lt;/msisdn&gt; &lt;/message&gt;
  </code></pre>
  
  <p>Here is the code, i have cut off everything unnecessary:</p>
  
  <pre><code>NodeList nodeLst = doc.getElementsByTagName("message");
  
  for (int s = 0; s &lt; nodeLst.getLength(); s++) {
  
         Node fstNode = nodeLst.item(s);
  
         if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
  
                 Element fstElmnt = (Element) fstNode;
  
                 NodeList numberNmElmntLst = fstElmnt
                 .getElementsByTagName("msisdn");
                 Element numberNmElmnt = (Element) numberNmElmntLst.item(0);
                 NodeList numberNm = numberNmElmnt.getChildNodes();
                 String phoneNumber = ((Node) numberNm.item(0))
                 .getNodeValue().substring(2);
  
                 NodeList txtNmElmntLst = fstElmnt
                 .getElementsByTagName("text");
                 Element txtNmElmnt = (Element) txtNmElmntLst.item(0);
                 NodeList txtNm = txtNmElmnt.getChildNodes();
                 String text = ((Node) txtNm.item(0)).getNodeValue();
  
                 NodeList rcvNmElmntLst = fstElmnt
                 .getElementsByTagName("received");
                 Element rcvNmElmnt = (Element) rcvNmElmntLst.item(0);
                 NodeList rcvNm = rcvNmElmnt.getChildNodes();
                 String recievedDate = ((Node) rcvNm.item(0)).getNodeValue();
              }
  }       
  </code></pre>
  
  <p>Can anyone guide me how this is done?</p>
  
  <p>Thanks in advance.</p>