R. Blaine Mincey wrote:
>I am experiencing a problem that I thought was fairly simple to resolve
>but I am now at the point of walking off the balcony --- well, maybe I
>won't go that far since I still have to see the latest "Star
>Wars"...anyway, I am parsing some integer values out of an XML
>document. The XML document is almost as simple as:
>
><Record>
> <Year>2001</Year>
> <Week>23</Week>
> <Code>1</Code>
></Record>
>
>Within the characters() method, I pass the String value to a separate
>method that keeps a reference to a "Record" object. Before setting
>week, year, so on, I keep getting a NumberFormatException when I do a
>Integer.parseInt(elementValue) on the value I have parsed from the XML.
>I was just curious if anyone else has had this issue?
>
You don't show any code and that is where the problem will be. The fact
that you read the text in from an XML document is immaterial. The
NumberFormatException means there is something non-numberish in the
string. As a matter of course, in the characters() method, I always have:
String textBuffer = new String( ch, start, length ).trim();
because the XML standard allows whitespace before and/or after the text
but Integer.parseInt() does not. If you still get the exception, I would
start looking at those silly little things like lowercase "o" and "l"
instead of zero and one. I've seen little things like this reduce
experienced programmers to tears.
Not really. But they did get *awfully* frustrated. 8^}
Tomm
To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm