PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Extracting HTML
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Extracting HTML

Réponse
 
LinkBack Outils de la discussion
Vieux 11/05/2008, 19h45   #1
Jordi Aragones vilella
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Extracting HTML

Hi!

I have a problem, and I can't find the solution.

I'm developing an app, (with ruby on rails) and I'm trying to create a
PDF with some information that I have in my database.

The situation is the next one: In my database I have some fields that
contains HTML source, that text it was added using FCKeditor. And now
I'm trying to built a PDF using PDF::Writer, but the problem that I have
is when I'm trying to insert my text in the PDF appears (as is logical)
the HTML tags. My question is... Is there any function/plugin that
allows me to skip that source? Or convert from HTML to Text?

Thank you very much for your time.

Jordi
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 11/05/2008, 20h21   #2
Jordi Aragones vilella
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extracting HTML

Dan Diebolt wrote:
> require 'hpricot'
>
> doc=Hpricot("<h1>Hello World</h1>")
> doc.inner_text
> => "Hello World"




Hi!! Thanks a lot for your answer. I'm a newbie and I still need to
learn a lot from Ruby and his libraries...

It worked fine!! And now, I will deep a bit in this library, because I
suppose that with that one, I will be able to save some tags for my PDF
code, isn't it? (For example, bold, underline...).

Thanks again for your answer!


--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 11/05/2008, 20h55   #3
Phlip
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extracting HTML

Jordi Aragones vilella wrote:

>> require 'hpricot'


> Hi!! Thanks a lot for your answer. I'm a newbie and I still need to
> learn a lot from Ruby and his libraries...
>
> It worked fine!! And now, I will deep a bit in this library, because I
> suppose that with that one, I will be able to save some tags for my PDF
> code, isn't it? (For example, bold, underline...).


Use a SAX-style XML parser to parse your strings as XHTML. SAX means the
parser calls a method for each tag it finds, so if you bind a <b> or <u> tag
you can stream the contents into PDF.

Now google for [ruby xml sax], because I don't know what Ruby's SAX solution
is!

--
Phlip


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h37.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07255 seconds with 11 queries