How to find Node attribute value and delete it in XML with Java DOM parser
<p>How can I find and delete item id="s2" using Java DOM parser?</p>

<pre><code>&lt;manifest&gt;
    &lt;item href="html/section1.html" id="s1" media-type="application/xhtml+xml"/&gt;
    &lt;item href="html/section2.html" id="s2" media-type="application/xhtml+xml"/&gt;
    &lt;item href="html/section3.html" id="s3" media-type="application/xhtml+xml"/&gt;
&lt;/manifest&gt;
</code></pre>

<p>I use this code but return Null</p>

<pre><code>Node metadataXML = doc.getElementsByTagName("manifest").item(0);
        NodeList list = metadataXML.getChildNodes();
        for (int i = 0; i &lt; list.getLength(); i++) {
            list.item(i).getAttributes().removeNamedItem("s2");
        }
</code></pre>