Im trying to read the value of an attribute called "version" from a tree. The value of that is "2.0". I set an if statement asking if the attribute value is equal to 2.0 to run this code, instead it runs the else statement. I got confused to i made a boolean value and set it equal to the equation. I print it out and it reads false when it is indeed true. Here is my code:
out.print("Enter the URL of an RSS 2.0 news feed: ");
String url = in.nextLine();
XMLTree xml = new XMLTree1(url);
boolean t = xml.hasAttribute("version");
if (t) {
out.println(xml.attributeValue("version"));//this prints 2.0
boolean a = (xml.attributeValue("version") == "2.0"); //added this to debugg
out.println(a); //this gets set to false. why?
if (xml.attributeValue("version") == "2.0") {
out.println("Hello");
} else {
out.println("URL entered is not of version 2.0");
}
} else {
out.println("No attribute Version");
}
/*
* TODO: fill in body
*/
in.close();
out.close();
}
}
Im entering the URL: http://news.yahoo.com/rss/, which its tree has a root tag "rss" that has an attribute "version" who is equal to 2.0: