here n2 is my NodeList, and i just want to see the first child node of my root element
public void ClickMe(View view){
Node rootElement=n2.item(0);
Try it like this....
NodeList LOP = odoc.getElementsByTagName("Your_XML_Top_Element");
Node FPN =LOP.item(0);
try{
if(FPN.getNodeType() == Node.ELEMENT_NODE)
{
Element token = (Element)FPN;
NodeList oNameList1 = token.getElementsByTagName("Your_XML_Sub_Node");
Element firstNameElement = (Element)oNameList1.item(0);
NodeList textNList1 = firstNameElement.getChildNodes();
}
If node is element then only cast it. Make check like below.
if (first.getNodeType() == Node.ELEMENT_NODE) { Element nm=(Element)first;}