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 > tag, tag_end in parser
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
tag, tag_end in parser

Réponse
 
LinkBack Outils de la discussion
Vieux 01/12/2007, 07h05   #1
Martin Durai
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut tag, tag_end in parser

I have created a buffer class and i was able to read a character, string
and write in the buffer. Iam in process of creating pull parser. Now iam
parsing only with strings. if i give a string
"<abc>defgh</abc><def>ijk</def>" as a string input i need to check the
starting of tag and end of tag. could any one me to do tag_start
and tag_end method.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 01/12/2007, 08h01   #2
Phrogz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tag, tag_end in parser

On Nov 30, 11:05 pm, Martin Durai <mar...@angleritech.com> wrote:
> I have created a buffer class and i was able to read a character, string
> and write in the buffer. Iam in process of creating pull parser. Now iam
> parsing only with strings. if i give a string
> "<abc>defgh</abc><def>ijk</def>" as a string input i need to check the
> starting of tag and end of tag. could any one me to do tag_start
> and tag_end method.


Check out String#scan method with regexp %r{</?\S>} and StringScanner
class (require 'strscan').
  Réponse avec citation
Vieux 01/12/2007, 08h17   #3
MonkeeSage
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tag, tag_end in parser

On Dec 1, 12:05 am, Martin Durai <mar...@angleritech.com> wrote:
> I have created a buffer class and i was able to read a character, string
> and write in the buffer. Iam in process of creating pull parser. Now iam
> parsing only with strings. if i give a string
> "<abc>defgh</abc><def>ijk</def>" as a string input i need to check the
> starting of tag and end of tag. could any one me to do tag_start
> and tag_end method.
> --
> Posted viahttp://www.ruby-forum.com/.


You sure like doing needless work! First, you re-implemented StringIO
(as was pointed out to you before), and now you want to re-implement a
stream-based XML processing module? There is a reason why you didn't
get a meaningful response when you asked this question several days
ago.

Just for starters, properly parsing XML would require writing an LL(2)
lexer for the grammar. And why try to re-invent the wheel when there
are already plenty of stream-based/supporting XML processing libraries
with ruby bindings. In fact, the built-in, pure ruby REXML supports
stream processing. And even though REXML is (relatively) slow, it will
probably be faster than anything you (or I) might write.

Unless this is some sort of school assignment, why put yourself
through all the trouble of creating what already exists? And if it is
an assignment, just asking us to do it for you won't you in the
long term anyhow--try it yourself and only ask for where you get
stuck (google is your friend).

Regards,
Jordan
  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 20h36.


Édité par : vBulletin® version 3.7.4
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 ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15550 seconds with 11 queries