I have the following xml document and i want to remove the element sub_element with the value of test2.
<element>
<element-name>Readers</element-name>
<dynamic>no</dynamic>
<html>readers.html</html>
</element>
<element>
<element-name>
test</element-name>
<dynamic>yes</dynamic>
<html>leftbankart[1].html</html>
<sub_element>test2</sub_element>
</element>
However when I do it removes the entire element node and i end up with
<element>
<element-name>Readers</element-name>
<dynamic>no</dynamic>
<html>readers.html</html>
</element>
dom = documentBuilder.parse(in);
node = XPathAPI.selectSingleNode(dom,"/elements/element[sub_element='" + value + "']");
Node parentNode = node.getParentNode();
parentNode.removeChild(node);
What am I doing wrong? Thank you for your time