# How to use hpricot in views

**URL:** <https://www.ruby-forum.com/t/how-to-use-hpricot-in-views/143985>\
**Category:** Ruby\
**Created:** [July 24, 2008, 12:31pm UTC](https://www.ruby-forum.com/t/how-to-use-hpricot-in-views/143985 "2008-07-24T12:31:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lostwarrior](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@lostwarrior](https://www.ruby-forum.com/u/lostwarrior)\
**Post date:** [July 24, 2008, 12:31pm UTC](https://www.ruby-forum.com/t/how-to-use-hpricot-in-views/143985/1 "2008-07-24T12:31:39Z")

</div>

how to parse xml file in html.erb  
\<%  
xml = Hpricot.parse(@chunk\_of\_xml\_data)  
data = (xml/:uid) %\>  
\<% data.each { |u| %\>  
\<%= u.innerHTML %\>  
\<% } %\>

---

<div class="post-metadata">

**Author:** ![lostwarrior](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@lostwarrior](https://www.ruby-forum.com/u/lostwarrior)\
**Post date:** [July 24, 2008, 3:05pm UTC](https://www.ruby-forum.com/t/how-to-use-hpricot-in-views/143985/2 "2008-07-24T15:05:40Z")

</div>

On Thu, Jul 24, 2008 at 07:25:51PM +0900, Lost W. wrote:

> how to parse xml file in html.erb  
> \<%  
> xml = Hpricot.parse(@chunk\_of\_xml\_data)  
> data = (xml/:uid) %\>  
> \<% data.each { |u| %\>  
> \<%= u.innerHTML %\>  
> \<% } %\>

This does not belong in the view. Put it either in the controller or the  
helper.

–Greg
