title: How Can I Remove Child of A node list?
body: <p>I'am new in java and android. I have an XML file Like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SendList&gt;
     &lt;listdata&gt;
         &lt;name&gt;aaaaaa&lt;/name&gt;
         &lt;message&gt;xfhjj&lt;/message&gt;
         &lt;tel&gt;1111222&lt;/tel&gt;
         &lt;icon&gt;list&lt;/icon&gt;
     &lt;/listdata&gt;
     &lt;listdata&gt;
         &lt;name&gt;bbbbbbbbb&lt;/name&gt;
         &lt;message&gt;ghjchjxff&lt;/message&gt;
         &lt;tel&gt;45885367&lt;/tel&gt;
         &lt;icon&gt;list&lt;/icon&gt;
     &lt;/listdata&gt;
     &lt;listdata&gt;
         &lt;name&gt;ccccccc&lt;/name&gt;
         &lt;message&gt;hkggcckj&lt;/message&gt;
         &lt;tel&gt;46964788&lt;/tel&gt;
         &lt;icon&gt;list&lt;/icon&gt;
     &lt;/listdata&gt;
  &lt;/SendList&gt;
  </code></pre>
  
  <p>I want to delete each of node  but with this code i use I receive Null pointer Exception except last Node !</p>
  
  <pre><code>                        Node no = document.getFirstChild();
                          NodeList nl = no.getChildNodes();
                          for (int n = 0; n &lt; nl.getLength(); n++) {
                              Node list = document.getElementsByTagName("listdata").item(n);
                              NodeList nodes = list.getChildNodes();
                              for (int i = 0; i &lt; nodes.getLength(); i++) {
                                  Node element = nodes.item(i);
                                  String t = element.getFirstChild().getTextContent();
                                  if (deleteValueName.equals(t)) {  \\deleteValueName for example equal aaaaaa OR bbbbbbbbb
                                      if ("name".equals(element.getNodeName())) {
                                          Node nd = element.getParentNode();
                                          Node ndParent = nd.getParentNode();
                                          ndParent.removeChild(nd);
                                      }
                                  }
                              }
                          }
  </code></pre>
  
  <p>Please Help Me !</p>