This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HtmlUnit - Iterating through DomNodes looking for specific node

 
Ryan Gray
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all!

I'm using HtmlUnit to get some values from a website. I'm creating an HtmlPage called page, getting page.getDescendants() in an Iterable<DomNode> named pageDesc. Then I iterate through pageDesc and use the if statement to look for the specific node <tr class="away">. The if statement below looks like it should work, but does not. I have an alternative way in comments that DOES work, but I would prefer to access the node using the way not in comments.
Let me know if you need more info or you have an idea to try. Thanks!

 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about you only get the table rows from the page, then iterate over them using getAttribute("class")?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic