[closed] [duplicate] Issue in removing a node
I am tried to remove one node with this code below.
But it is removing all nodes with this tag
NodeList defectList = (NodeList) doc.getElementsByTagName("oslc_cm:tracksWorkItem");
System.out.println("defectList.getLength() "+defectList.getLength());
for(int i=defectList.getLength()-1;i>=0;i--){
Element defect = (Element) defectList.item(i);
String link=defect.getAttribute("rdf:resource");
String id=link.substring(link.lastIndexOf("/")+1);
if (id.equals(defectID))
{
defect.getParentNode().removeChild(defect);
// doc.removeChild(defect);
System.out.println("Removing defect "+ defectID);
}
}
The question has been closed for the following reason: "Duplicate Question" by tmok Jul 23 '13, 2:49 p.m.