T
* Tong *
Hi,
I've been looking at HTML:
arser and HTML::LinkExtor trying to
figure out how to handle the html tags as a whole. But I'm still
confused and feel at lost about their even handling mechanism.
All that I'm trying to do is to call the following even handler
after a whole html link tag has bee parsed.
tag_handler(){
my ($tag, $tag_open, $tag_content, $tag_close) = @_;
...
}
So, '<A HREF="link.html">link</a> ' will give me:
($tag, $tag_open, $tag_content, $tag_close) =
('a', 'A HREF="link.html"', 'link', '/a');
and an '<IMG SRC="img.jpg" lowsrc="img.gif" alt="Image">' will give
me:
($tag, $tag_open, $tag_content, $tag_close) =
('img', 'IMG SRC="img.jpg" lowsrc="img.gif" alt="Image"', undef, undef);
Seems to me the right way is to start with is a general purpose
start handler, in which different end handlers are assigned
according to the start tag. This is where I get lost and don't
know how to do. I'm wondering if anyone could be kind enough to
provide me a first draft, showing me how this can be done. It will
be much appreciated.
NB, this is only to explain the concept. Maybe passing back the
html tag as HTML::Element/HTML::Entities so that the tag attributes
have already been processed is a better idea.
Thanks a lot.
I've been looking at HTML:
figure out how to handle the html tags as a whole. But I'm still
confused and feel at lost about their even handling mechanism.
All that I'm trying to do is to call the following even handler
after a whole html link tag has bee parsed.
tag_handler(){
my ($tag, $tag_open, $tag_content, $tag_close) = @_;
...
}
So, '<A HREF="link.html">link</a> ' will give me:
($tag, $tag_open, $tag_content, $tag_close) =
('a', 'A HREF="link.html"', 'link', '/a');
and an '<IMG SRC="img.jpg" lowsrc="img.gif" alt="Image">' will give
me:
($tag, $tag_open, $tag_content, $tag_close) =
('img', 'IMG SRC="img.jpg" lowsrc="img.gif" alt="Image"', undef, undef);
Seems to me the right way is to start with is a general purpose
start handler, in which different end handlers are assigned
according to the start tag. This is where I get lost and don't
know how to do. I'm wondering if anyone could be kind enough to
provide me a first draft, showing me how this can be done. It will
be much appreciated.
NB, this is only to explain the concept. Maybe passing back the
html tag as HTML::Element/HTML::Entities so that the tag attributes
have already been processed is a better idea.
Thanks a lot.