tag, tag_end in parser

M

Martin Durai

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 help me to do tag_start
and tag_end method.
 
P

Phrogz

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 help me to do tag_start
and tag_end method.

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

MonkeeSage

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 help me to do tag_start
and tag_end method.

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
 

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,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top