XML:
<nativeInformation>
<detail id="natural:fieldFormat">A</detail>
</nativeInformation>
I am trying to get the "id" value. but keep getting this error: org.apache.xerces.dom.DeferredTextImpl cannot be cast to org.w3c.dom.Element
My code:
for (int i = 0; i < nodeList.getLength(); i++) {
String s;
Node n = nodeList.item(i);
Attr attrName = ((Element) n).getAttributeNode("id");
if (attrName.getValue()!=null) {
s = attrName.getValue();
System.out.println(s);
}
}
If I write : System.out.println("parent node is "+n.getParentNode()); inside the for loop that will give me, [detail: null]
Any help will be really appreciated.