File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes HtmlUnit - Iterating through DomNodes looking for specific node Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HtmlUnit - Iterating through DomNodes looking for specific node" Watch "HtmlUnit - Iterating through DomNodes looking for specific node" New topic
Author

HtmlUnit - Iterating through DomNodes looking for specific node

Ryan Gray
Greenhorn

Joined: Sep 19, 2012
Posts: 1
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

Joined: Jan 28, 2003
Posts: 4181
    
  21

How about you only get the table rows from the page, then iterate over them using getAttribute("class")?


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HtmlUnit - Iterating through DomNodes looking for specific node