title: Android Parse XML Attribute
body: <p>I am parsing two xml files - the first I have successfully parsed using XmlParser:-</p>
  
  <pre><code>public final String getElementValue(Node elem) {
      Node child;
      if (elem != null) {
          if (elem.hasChildNodes()) {
              for (child = elem.getFirstChild(); child != null; child = child
                      .getNextSibling()) {
                  if (child.getNodeType() == Node.TEXT_NODE) {
                      System.out.println("±VALUE: "
                              + child.getNodeValue().toString()
                              + " node type: " + child.getNodeType());
                      return child.getNodeValue();
                  }
  </code></pre>
  
  <p>The next xml file however has attributes that I need. Can I use the same parser and if so how do I change it to read attributes? The file I want to read is <a href="http://cloud.tfl.gov.uk/TrackerNet/LineStatus" rel="nofollow">http://cloud.tfl.gov.uk/TrackerNet/LineStatus</a> - I need the Line name and Status Description.</p>
  
  <p>I am using another class with the KEYs in - how do I explicitly say which attribute I need? i.e. the below:- </p>
  
  <pre><code>static final String KEY_TRANSPORT = "LineStatus"; // parent node
  static final String KEY_LINENAME = "???";
  static final String KEY_LINEDESC = "???";
  </code></pre>
  
  <p>Thanks!</p>