We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › XML string problem
Page Index Toggle Pages: 1
XML string problem (Read 430 times)
XML string problem
Mar 16th, 2010, 4:53pm
 
I have this
Code:
 
String a = kid.getStringAttribute("shape");
if(a == "square") {
fill( kid.getIntAttribute("color") );
rect( kid.getIntAttribute("x"), kid.getIntAttribute("y"), kid.getIntAttribute("size"), kid.getIntAttribute("size") );
}


and the xml is this.
Code:
<?xml version="1.0"?>
<shapes>
<site shape="square" size="100" color="#ccaa88" x="199" y="11" />
<site shape="circle" size="50" color="#1155ff" x="100" y="100" />
</shapes>



The shape attribute shows up as a 'square' or 'circle' but the if condition doesn't trigger. It's the strangest thing.

thanks for any insights.

Re: XML string problem
Reply #1 - Mar 16th, 2010, 9:17pm
 
I found the answer... It was the string condition, it should be
Code:

if (a.equals("square") {
......


I guess Strings has a different way of doing things.
Page Index Toggle Pages: 1