FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Integration
(Moderators: fry, REAS)
   nanoxml attribute type?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: nanoxml attribute type?  (Read 401 times)
5cameron

WWW
nanoxml attribute type?
« on: Jan 6th, 2005, 3:44pm »

Hi,
 
I'm working with the nanoxml parser, implimented using this as a reference:
http://processing.org/discourse/yabb/board_Tools_action_display__num_1070627124.html
 
and I've got this piece of code:
 
String tempVar = (String)node.getAttribute("name");
    String tempVar2 = "index.html";
    if(tempVar==tempVar2){
 println(tempVar+" IS equal to index.html");
    }else{
 println(tempVar+" IS NOT equal to index.html");
    }
 
when the node im trying to find comes up, Processing tells me "index.html IS NOT equal to index.html".
 
anyone else experienced this, or have suggestions
 
thanks!
 
5
 
TomC

WWW
Re: nanoxml attribute type?
« Reply #1 on: Jan 6th, 2005, 3:51pm »

The == operator tests if Strings refer to the same memory, not if they contain the same characters.  You need to use the equals method of the string to do a lexicographic match.
 
I explain this better here:
 
http://processing.org/discourse/yabb/board_Synta_x_action_display_num_1100632237.html#4
 
(this is already in my Java for Processing FAQ, coming Real Soon Now)
« Last Edit: Jan 6th, 2005, 3:51pm by TomC »  
5cameron

WWW
Re: nanoxml attribute type?
« Reply #2 on: Jan 7th, 2005, 6:36am »

I knew it was something like that.  
 
Thanks so much!!
 
5
 
Pages: 1 

« Previous topic | Next topic »