Ah, the joy of Java strings!
The equality operator compares the
references, not the content of the strings. To compare two strings for equality, you need to use the
equals
method.
if (a.equals(b)) {
NB: Rather than converting both strings to lower-case, you could use
the equalsIgnoreCase
method[
^]:
String a = nd.getNodeName().toString().trim();
String b = feld.toString().trim();
if (a.equalsIgnoreCase(b)) {
However, XML is designed to be case-sensitive, so this could be a bug in your code.