I am parsing an xml using DOM Parser. I get a doc and then from that doc i get a url. when i search through that url for a particular char sequence i receive a null pointer exception.
This is what i am doing:
Boolean var = false;
String url = theElement.getChildNodes().item(5).getNodeValue();
if (url.contains("-b-")) // this throws exception
{
var = true;
}
Please any suggestions…
These long chains of “dereference” operations often cause problems if one or more of them results in a null pointer.
Before setting
url, print out the values for:Almost certainly the last one will be a null reference.
The documentation for
String.containsshows no specific exception is thrown, hence the likelihood is high that it’s a null reference (especially, as I’ve just noticed, you explicitly state that it’s a null pointer exception).