James,
Adding trim() to the getNodeValue() method will resolve your white space
issues as well, as opposed to any parser configuration setting.
if (node.getNodeValue().trim().equalsIgnoreCase("true"))
Ed
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of James Ostheimer
Sent: Monday, November 27, 2006 10:58 AM
To: [email protected]
Subject: Re: Problem with Xerces DOM (newbie)
Thanks to Peter and Ed for the reply they helped me figure out
that I shouldn't have trusted the debugger in this case!
I got it working now!
James
On 11/27/06, Peter McCracken <[EMAIL PROTECTED]> wrote:
Hi James,
[EMAIL PROTECTED] wrote on 27/11/2006 11:27:20
AM:
> I have been using java for quite a while, but this is
my first
> experience with the DOM parser and Xerces. My issue
is that I can't
> seem to get the parser to parse a very simple XML
file.
I tried out the code sample you provided (with the
exception that I hard coded the String variable instead of using a
WebResponse object) and it worked fine for me, using Xerces 2.9.0. I
assume you've verified that the "text" variable contains the XML that
you expect it to contain? Have you tried executing the piece of code
that you sent as a standalone application to verify that it's really
that section that's causing the problem?
> The NodeList nl, is empty (verified by eclipse
debugger). This I
> just do not uderstand, the XML is well-formed and very
simple and I
> should be able to get something by tag name even
without a DTD.
One caveat is that the NodeList object will look like it
is empty in a debugger when you first get it. For performance reasons,
Xerces defers filling the NodeList until you actually ask for nodes from
the list. If you call getLength() on the NodeList, it will walk the
entire DOM tree and fully populate the list. If you call item(N)
without calling getLength(), Xerces will find only the first N items
without parsing the entire XML tree. This is useful in cases where
you're processing a large DOM tree but only want the first occurrence of
a particular tag.
Cheers,
--
Peter McCracken
XML Parser Development
IBM Toronto Lab
Email: [EMAIL PROTECTED]