Get value in XML by NodeList not display
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/10662747/get-value-in-xml">Get value in XML</a>  </p>
</blockquote>



<p>I have this link: <a href="http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=westlife&amp;song=my%20love" rel="nofollow">http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=westlife&amp;song=my%20love</a> and I want to get lyric in tag </p>

<p>I use NodeList but it not display </p>

<p>public class ParseXMLAppActivity extends Activity {</p>

<pre><code>public static String str_lyric;
TextView tv;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    new DoInBackground().execute();
}

public void initialLayout()
{
    tv=(TextView)findViewById(R.id.textview);
    tv.setText(str_lyric);
}

public void parse()
{
    URL url;
    try {
        url = new URL("http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?  
            artist=westlife&amp;song=Fool%20Again");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();

            Document doc = builder.parse(url.openStream());

            NodeList labTestList = doc.getElementsByTagName("GetLyricResult");

            Element labTest = (Element)labTestList.item(0);

            NodeList lyric=labTest.getElementsByTagName("Lyric");

                str_lyric=lyric.item(0).getChildNodes().item(0).getNodeValue();
                //Log.d("llllllllllllkdasjf",str_lyric);

        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}
</code></pre>

<p>private class DoInBackground extends AsyncTask implements DialogInterface.OnCancelListener
    {
        private ProgressDialog dialog;</p>

<pre><code>    protected void onPreExecute() 
    {
    dialog = ProgressDialog.show(ParseXMLAppActivity.this, "", "Đang tìm kiếm..Xin đợi chút", false);
    dialog.setCancelable(true);
    }

    protected Void doInBackground(Void... unused) 
    { 
    try {
        parse();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null; 
    }                

    protected void onPostExecute(Void unused) 
    {       
    initialLayout();
    dialog.dismiss(); 
    }

    public void onCancel(DialogInterface dialog) 
    { 
    cancel(true); 
    dialog.dismiss(); 
    }
    }
</code></pre>
