TextView not displaying data from xml file <p>I am trying to retrieve some data from my xml file. Below is the code which should be working but in this case it doesn't. I am not getting errors but data just doesn't gets displayed.Please review this code and tell me what's wrong here. (I am trying to look at an id, if it matches a certain digit than display text) Thanks.</p> <pre><code>String stringXmlContent; try { stringXmlContent = getEventsFromAnXML(this); tv.setText(stringXmlContent); } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } button1.setOnClickListener(this); } private String getEventsFromAnXML(Activity activity)throws XmlPullParserException, IOException { StringBuffer stringBuffer = new StringBuffer(); String attVal = null; String desc; Resources res = activity.getResources(); XmlResourceParser xrp = res.getXml(R.xml.myxml); try { xrp.next(); int eventType = xrp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if(eventType == XmlPullParser.START_DOCUMENT) { stringBuffer.append(" "); } if(eventType == XmlPullParser.START_TAG) { if(xrp.getName().equals("Number")){ attVal = xrp.getAttributeValue(0); } } else if(eventType == XmlPullParser.TEXT) { if(xrp.getName().equals("Description") &amp;&amp; attVal.equals("2")){ stringBuffer.append(" " + xrp.getText()); } } } } catch (XmlPullParserException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return stringBuffer.toString(); </code></pre>