The test() function below checks if the element matches a predefined namespace NSURI:
class MyClass {
private static final String NSURI = "http://example.com/mynamespace";
...
public test(Element e) {
return NSURI.equals(e.getNamespaceURI());
}
}
Is the string comparison efficient? I have to iterate many nodes, potentially having different namespaces. But, doing a string comparison each time seems wasteful.
Is there a faster way to do a namespace comparison?