<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [jdom-interest] passing string from jdom tree to if statement</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Your problem isn't with JDOM, it's how you are evaluating equality of your string.</FONT>
</P>
<P><FONT SIZE=2>Try</FONT>
</P>
<P><FONT SIZE=2>if(ok.equals("Send")){</FONT>
<BR> <FONT SIZE=2>...</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>
<BR>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Trond Fuglestad [<A HREF="mailto:tfuglest@c2i.net">mailto:tfuglest@c2i.net</A>]</FONT>
<BR><FONT SIZE=2>Sent: Wednesday, May 15, 2002 8:54 AM</FONT>
<BR><FONT SIZE=2>To: jdom-interest@jdom.org</FONT>
<BR><FONT SIZE=2>Subject: [jdom-interest] passing string from jdom tree to if statement</FONT>
</P>
<BR>
<P><FONT SIZE=2>I am trying to get the contents of a an element in a jdom tree, and then use</FONT>
<BR><FONT SIZE=2>this value (a String) in an if-statement.</FONT>
<BR><FONT SIZE=2>My problem is, that when i try to use this String in the if-statement, it</FONT>
<BR><FONT SIZE=2>does not match, and the else-statement is printed.</FONT>
<BR><FONT SIZE=2>What I find strange is that when I use System.out.println it prints the</FONT>
<BR><FONT SIZE=2>right value.</FONT>
<BR><FONT SIZE=2>Very grateful if anyone can help me with this!</FONT>
</P>
<P><FONT SIZE=2>Here is the code:</FONT>
</P>
<P><FONT SIZE=2>private void docType (Document doc)</FONT>
<BR><FONT SIZE=2> { Element chk = doc.getRootElement();</FONT>
<BR><FONT SIZE=2> String type =</FONT>
<BR><FONT SIZE=2>chk.getChild("header").getChild("command").getTextNormalize(); //Or</FONT>
<BR><FONT SIZE=2>getText() or getTextTrim()</FONT>
</P>
<P><FONT SIZE=2> System.out.println(type); //Used for testing purposes, prints Send</FONT>
<BR><FONT SIZE=2> System.out.println(type.length()); //Used for testing purposes, prints 4</FONT>
<BR><FONT SIZE=2> if (ok == "Send")</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2> System.out.println("Send loop");</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> else</FONT>
<BR><FONT SIZE=2> {System.out.println("feil");}</FONT>
</P>
<BR>
<P><FONT SIZE=2>Trond Fuglestad</FONT>
</P>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>To control your jdom-interest membership:</FONT>
<BR><FONT SIZE=2><A HREF="http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com" TARGET="_blank">http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com</A></FONT>
</P>
</BODY>
</HTML>