There is an XML file:
<?xml version="1.0" encoding="UTF-8"?> <studentsList> <student> <code>0</code> <lastName>bessonov</lastName> <firstName>leonid</firstName> <patronymic>valentinovich</patronymic> <phone>89061234567</phone> </student> <student> <code>1</code> <lastName>petrov</lastName> <firstName>leonid</firstName> <patronymic>valentinovich</patronymic> <phone>89000000000</phone> </student> </studentsList>
You must compare the last last name in $ lastName with the lastName fields in the file.
NodeList nodeList = doc.getElementsByTagName("student"); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if(node.getChildNodes().item(1).getNodeValue().equals($lastName) == true){ }
Such if gives me a NullPointerException. Google hasn't helped yet.