Problem converting to INT from an XML file
Hi folks, I hope you can help with this one, as it's been driving me nuts...
Basically (and I'll try to keep this brief!) my project takes in an extremely basic XML file. I've never really done this before, but I seem to have got most of it working apart from taking in attribute values which I want to use as integers.
Essentially, each element relates to objects of a basic class I have set up, while each attribute relates to the variables for the object. When the XML file is read, a new object is set up for each element and is stored in a linked list. That was *supposed* to be the difficult bit, but it turns out it hasn't been...
The XML file looks a little bit like this (only the elements are shown to save space):
<Object name="My object" description ="blah" x_axis ="96" y_axis="23" />
<Object name="Another one" description ="blah, again" x_axis ="83" y_axis="40"/>
etc. etc.
The problem relates to the x_axis and y_axis attributes. While the description and name attributes are assigned correctly, for some reason the x_axis and y_axis attributes are both given values of zero when I convert them from Strings to Ints. After much printing to the console, kicking and screaming, I think I've narrowed the problem down to the following code:
if (attrib.getName() =="x_axis")
{
int myX = Integer.parseInt(attrib.getValue());// converting a string to an int
myObject.setSoundX_Axis(myX);
}
// And, of course, I do the same sort of thing for the Y axis.
Anyone know why I'm getting zero values? Is it something to do with the way I'm converting the string to an int in Java?
Cheers for any help.

