# Parsing of Html/Text files

**URL:** <https://www.ruby-forum.com/t/parsing-of-html-text-files/181044>\
**Category:** Ruby\
**Created:** [January 4, 2010, 12:22pm UTC](https://www.ruby-forum.com/t/parsing-of-html-text-files/181044 "2010-01-04T12:22:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [January 4, 2010, 12:22pm UTC](https://www.ruby-forum.com/t/parsing-of-html-text-files/181044/1 "2010-01-04T12:22:39Z")

</div>

Hi Guyz, back with a new problem 🙂

Actually the situation is that i have a txt file or can be html file. In  
that file the contents are written as:-  
Model Name:- ABC  
Item Name :- ABC

There are hundreds of lines for it. Now, i am matching these line and  
where ever i’ll find the line model name. I’ll get it. So right now i am  
doing it as,  
if file\_line.match(“Model Name”) … Is there any other way to do it  
using parsers? I mean using Hpricot or else … want to know every  
possible way to do this.

Thanks

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [January 4, 2010, 12:25pm UTC](https://www.ruby-forum.com/t/parsing-of-html-text-files/181044/2 "2010-01-04T12:25:16Z")

</div>

El Lunes, 4 de Enero de 2010, Hemant B. escribiÃ³:

> if file\_line.match(“Model Name”) … Is there any other way to do it  
> using parsers? I mean using Hpricot or else … want to know every  
> possible way to do this.

When that text is contained in a HTML file, is it alawys enclosed in the  
same  
HTML tag?

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [January 4, 2010, 12:27pm UTC](https://www.ruby-forum.com/t/parsing-of-html-text-files/181044/3 "2010-01-04T12:27:18Z")

</div>

I am not using any tags for text. Ok leave html part. Help me only with  
text file. 🙂

IÃ±aki Baz C. wrote:

> El Lunes, 4 de Enero de 2010, Hemant B. escribiÃ³:
> 
> > if file\_line.match(“Model Name”) … Is there any other way to do it  
> > using parsers? I mean using Hpricot or else … want to know every  
> > possible way to do this.
> 
> When that text is contained in a HTML file, is it alawys enclosed in the  
> same  
> HTML tag?

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [January 4, 2010, 12:51pm UTC](https://www.ruby-forum.com/t/parsing-of-html-text-files/181044/4 "2010-01-04T12:51:01Z")

</div>

El Lunes, 4 de Enero de 2010, Hemant B. escribiÃ³:

> I am not using any tags for text. Ok leave html part. Help me only with  
> text file. 🙂

Then using pure regex is good enough. If you want something “cooler” try  
TreeTop parser (very friendly and powerful).
