Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
aleph1
Apr 16, 2004

Carthag posted:

But I can't find any methods on Element for iterating sequentially on them like this?

Element is a subclass of Node, so your code should work just fine?

Edit: the reason your code is not working is because you can't get the text contained in an element by calling getNodeValue() on it - that always returns null.
The text you want is in the child of that element node as a text node, so what you want to do instead is:
code:
String value = node.getFirstChild().getNodeValue();
(and possibly check that the child actually exists and is of Node.TEXT_NODE type)

aleph1 fucked around with this message at 17:45 on Nov 10, 2010

Adbot
ADBOT LOVES YOU

aleph1
Apr 16, 2004

Harold Ramis Drugs posted:

ugh, i'm just going to write that little detail off as a typo then. Thanks

What was meant was probably: don't use raw arrays, instead use the Collections framework (List/Set/etc), which is good advice for people just starting out with Java.

aleph1
Apr 16, 2004

No Safe Word posted:

code:
run_once = false;
while (<condition> AND run_once) {
    ... stuff ...
    run_once = true;
}

I think you meant:

code:
run_once = true;
while (<condition> OR run_once) {
    ... stuff ...
    run_once = false;
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply