Parsing of Html/Text files

  • Thread starter Hemant Bhargava
  • Start date
H

Hemant Bhargava

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
 
I

Iñaki Baz Castillo

El Lunes, 4 de Enero de 2010, Hemant Bhargava escribi=C3=B3:
Hi Guyz, back with a new problem :)
=20
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
=20
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.

When that text is contained in a HTML file, is it alawys enclosed in the sa=
me=20
HTML tag?


=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
H

Hemant Bhargava

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

Iñaki Baz Castillo

El Lunes, 4 de Enero de 2010, Hemant Bhargava escribi=C3=B3:
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=20
TreeTop parser (very friendly and powerful).

=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top