how to set message if no XML or Document found
<pre><code>  public class AndroidXMLParsingActivity extends Activity {

            public int currentPage = 1;
            public ListView lisView1;
            static final String KEY_ITEM = "docdetails";
            static final String KEY_NAME = "heading";
            public Button btnNext;
            public Button btnPre;
            public static String url = "http://dev.taxmann.com/TaxmannService/TaxmannService.asmx/GetNotificationList";

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

                // listView1
                lisView1 = (ListView) findViewById(R.id.listView1);

                // Next
                btnNext = (Button) findViewById(R.id.btnNext);
                // Perform action on click
                btnNext.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        currentPage = currentPage + 1;
                        ShowData();
                    }
                });

                // Previous
                btnPre = (Button) findViewById(R.id.btnPre);
                // Perform action on click
                btnPre.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        currentPage = currentPage - 1;
                        ShowData();
                    }
                });

                ShowData();
            }

            public void ShowData() {
                XMLParser parser = new XMLParser();
                String xml = parser.getXmlFromUrl(url); // getting XML

                Document doc = parser.getDomElement(xml); // getting DOM element

                NodeList nl = doc.getElementsByTagName(KEY_ITEM);

                int displayPerPage = 5; // Per Page
                int TotalRows = nl.getLength();
                int indexRowStart = ((displayPerPage * currentPage) - displayPerPage);
                int TotalPage = 0;
                if (TotalRows &lt;= displayPerPage) {
                    TotalPage = 1;
                } else if ((TotalRows % displayPerPage) == 0) {
                    TotalPage = (TotalRows / displayPerPage);
                } else {
                    TotalPage = (TotalRows / displayPerPage) + 1; // 7
                    TotalPage = (int) TotalPage; // 7
                }
                int indexRowEnd = displayPerPage * currentPage; // 5
                if (indexRowEnd &gt; TotalRows) {
                    indexRowEnd = TotalRows;
                }

                // Disabled Button Next
                if (currentPage &gt;= TotalPage) {
                    btnNext.setEnabled(false);
                } else {
                    btnNext.setEnabled(true);
                }

                // Disabled Button Previos
                if (currentPage &lt;= 1) {
                    btnPre.setEnabled(false);
                } else {
                    btnPre.setEnabled(true);
                }

                // Load Data from Index
                int RowID = 1;
                ArrayList&lt;HashMap&lt;String, String&gt;&gt; menuItems = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
                HashMap&lt;String, String&gt; map;

                // RowID
                if (currentPage &gt; 1) {
                    RowID = (displayPerPage * (currentPage - 1)) + 1;
                }

                for (int i = indexRowStart; i &lt; indexRowEnd; i++) {
                    Element e = (Element) nl.item(i);
                    // adding each child node to HashMap key =&gt; value
                    map = new HashMap&lt;String, String&gt;();
                    map.put("RowID", String.valueOf(RowID));
                    map.put(KEY_NAME, parser.getValue(e, KEY_NAME));

                    // adding HashList to ArrayList
                    menuItems.add(map);

                    RowID = RowID + 1;

                }

                SimpleAdapter sAdap;
                sAdap = new SimpleAdapter(AndroidXMLParsingActivity.this, menuItems,
                        R.layout.list_item, new String[] { "RowID", KEY_NAME },
                        new int[] { R.id.ColRowID, R.id.ColName });
                lisView1.setAdapter(sAdap);
            }

        }
</code></pre>

<p>This is my Parser class</p>

<pre><code>     public class XMLParser {

            // constructor
            public XMLParser() {

            }

            /**
             * Getting XML from URL making HTTP request
             * @param url string
             * */
            public String getXmlFromUrl(String url) {
                String responseBody = null;


                getset d1=new getset();
                String d=d1.getData();   //text
                String y=d1.getYear();   //year
                String c=d1.getCircular();
            String p=d1.getPage();


                List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                 nameValuePairs.add(new BasicNameValuePair("YearID", y));

                 nameValuePairs.add(new BasicNameValuePair("CircularNo", c));

                 nameValuePairs.add(new BasicNameValuePair("SearchText", d));
                 nameValuePairs.add(new BasicNameValuePair("pagenumber", p));
                try {

                    HttpClient httpclient=new DefaultHttpClient();
                    HttpPost httppost=new HttpPost(url);
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                    HttpResponse response = httpclient.execute(httppost);




                    HttpEntity entity = response.getEntity();

                     responseBody = EntityUtils.toString(entity);
        /           
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                } catch (ClientProtocolException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                // return XML
                return responseBody;
            }

            /**
             * Getting XML DOM element
             * @param XML string
             * */
            public Document getDomElement(String xml){
                Document doc = null;
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                try {

                    DocumentBuilder db = dbf.newDocumentBuilder();

                    InputSource is = new InputSource();
                        is.setCharacterStream(new StringReader(xml));
                        doc = db.parse(is); 

                    } catch (ParserConfigurationException e) {
                        Log.e("Error: ", e.getMessage());
                        return null;
                    } catch (SAXException e) {
                        Log.e("Error: ", e.getMessage());
                        return null;
                    } catch (IOException e) {
                        Log.e("Error: ", e.getMessage());
                        return null;
                    }

                    return doc;
            }

            /** Getting node value
              * @param elem element
              */
             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  ){
                                 return child.getNodeValue();
                             }
                         }
                     }
                 }
                 return "";
             }

             /**
              * Getting node value
              * @param Element node
              * @param key string
              * */
             public String getValue(Element item, String str) {     
                    NodeList n = item.getElementsByTagName(str);        
                    return this.getElementValue(n.item(0));
                }
        }
</code></pre>

<p>I want to set Toast Message if no Xml or Document will get null and give Exception please tell me how to Implement this i tried much but not able to do. I'm new in android.</p>
