I am trying to get an element by id in Java with Document object (org.w3c.dom.Document), but when I use the function getElementById(elementId) is returning a null. The Document Object is creating Ok, because I use getElementByTags and works fine.
My code in Java:
DocumentBuilder dbRespuesta0 = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document docRespuesta0 = dbRespuesta0.parse(new InputSource(new StringReader(context.getProperty("XML").toString())));
Element e = (Element) docRespuesta0.getElementById("ID_X");
The structure of my XML
<RESULT>
<TAG1 ID="A">
</TAG1>
<TAG1 ID="B">
</TAG1>
<TAG2 DIM="30" ID="C" SIZE="2">
</TAG2>
<TAG2 DIM="300" ID="ID_X" SIZE="2">
<TAG3 NUM="1">
</TAG3>
<TAG3 NUM="2">
</TAG3>
</TAG2>
</RESULT>
When I print the element e, I watch a null. I hope to getting in the element e, the next XML:
<TAG2 DIM="300" ID="ID_X" SIZE="2">
<TAG3 NUM="1">
</TAG3>
<TAG3 NUM="2">
</TAG3>
</TAG2>