title: Java - Delete child node from dynamic XML
body: <p>I want to delete a <strong>XML node</strong> that contains a PDF in Base64. This is an example:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;getResult&gt;
     &lt;id&gt;null&lt;/id&gt;
     &lt;pdf&gt;ioje98fh23fjkiwf72322342&lt;/pdf&gt;
  &lt;/getResult&gt;
  </code></pre>
  
  <p>First, I transform the XML in String to Document but the result is null. This is my code:</p>
  
  <pre><code>DocumentBuilder dbf = null;
  Document doc = null;
  
  try {
      dbf = DocumentBuilderFactory.newInstance().newDocumentBuilder();
  
      InputSource is = new InputSource();
      is.setCharacterStream(new StringReader("&lt;getResult&gt;&lt;id&gt;null&lt;/id&gt;&lt;pdf&gt;ioje98fh23fjkiwf72322342&lt;/pdf&gt;&lt;/getResult&gt;"));
  
      doc = dbf.parse(is);
  
      NodeList children = doc. getChildNodes();
  
      for (int i = 0; i &lt; children.getLength(); i++) {
  
          Node currentChild = children.item(i);
  
          System.out.println(currentChild);
  
      }
  
  } catch (Exception e) {
      System.out.println(e.getMessage().toString());
  }
  </code></pre>
  
  <p>The result is always: <code>[getResult: null]</code></p>
  
  <p>Considering that the main node can vary but the structure does not, How can I get the PDF node?</p>