# Tag, tag\_end in parser

**URL:** <https://www.ruby-forum.com/t/tag-tag-end-in-parser/121810>\
**Category:** Ruby\
**Created:** [December 1, 2007, 7:05am UTC](https://www.ruby-forum.com/t/tag-tag-end-in-parser/121810 "2007-12-01T07:05:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [December 1, 2007, 7:05am UTC](https://www.ruby-forum.com/t/tag-tag-end-in-parser/121810/1 "2007-12-01T07:05:44Z")

</div>

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  
“defghijk” as a string input i need to check the  
starting of tag and end of tag. could any one help me to do tag\_start  
and tag\_end method.

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [December 1, 2007, 8:05am UTC](https://www.ruby-forum.com/t/tag-tag-end-in-parser/121810/2 "2007-12-01T08:05:41Z")

</div>

On Nov 30, 11:05 pm, Martin D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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  
> “defghijk” as a string input i need to check the  
> starting of tag and end of tag. could any one help me to do tag\_start  
> and tag\_end method.

Check out String#scan method with regexp %r{\</?\S\>} and StringScanner  
class (require ‘strscan’).

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [December 1, 2007, 8:22am UTC](https://www.ruby-forum.com/t/tag-tag-end-in-parser/121810/3 "2007-12-01T08:22:37Z")

</div>

On Dec 1, 12:05 am, Martin D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 “defghijk” as a string input i need to check the starting of tag and end of tag. could any one help 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 help you in the  
long term anyhow–try it yourself and only ask for help where you get  
stuck (google is your friend).

Regards,  
Jordan
