# Screenscraping using htmltools and rexml

**URL:** <https://www.ruby-forum.com/t/screenscraping-using-htmltools-and-rexml/53065>\
**Category:** Ruby\
**Created:** [January 24, 2006, 4:42pm UTC](https://www.ruby-forum.com/t/screenscraping-using-htmltools-and-rexml/53065 "2006-01-24T16:42:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [January 24, 2006, 4:42pm UTC](https://www.ruby-forum.com/t/screenscraping-using-htmltools-and-rexml/53065/1 "2006-01-24T16:42:30Z")

</div>

Hi,  
I need to do some screen scraping and I’ve spent a couple hour getting  
htmltools and rexml do the right thing. Here’s the code:

parser = HTMLTree::Parser.new(false, false)  
parser.feed(res.body)  
tree = parser.tree.html\_node.as\_rexml\_document

I works for one page, but for another I get “undefined method `add’ for  
#HTMLTree::Element:0x37f9cc8” in as\_rexml\_document

It seems like a library mismatch, but I just downloaded ruby and all  
the libraries in the past couple days. Does anybody know what versions  
I need to make this work?

Thanks a lot!  
Peter

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [January 24, 2006, 4:45pm UTC](https://www.ruby-forum.com/t/screenscraping-using-htmltools-and-rexml/53065/2 "2006-01-24T16:45:32Z")

</div>

Btw, the versions I have now are:  
htmltools 1.09  
rexml 3.1.2.1

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [January 24, 2006, 4:45pm UTC](https://www.ruby-forum.com/t/screenscraping-using-htmltools-and-rexml/53065/3 "2006-01-24T16:45:32Z")

</div>

I have just tried rexml 3.1.3 and the “stable” version of rexml 2.4.8,  
but none of them work.
