Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Parsing HTML with tags intact

by mr_p (Scribe)
on Jan 07, 2011 at 13:51 UTC ( #881071=note: print w/replies, xml ) Need Help??


in reply to Re: Parsing HTML with tags intact
in thread Parsing HTML with tags intact

I can have misguided data as such. I have to be able to handle such data.

Replies are listed 'Best First'.
Re^3: Parsing HTML with tags intact
by ww (Archbishop) on Jan 07, 2011 at 14:17 UTC

    In that case, perldoc -f HTML::Parser raises the question (for me, anyway): "Is H::P the appropriate tool?

    "HTML::Parser" is not a generic SGML parser. We have tried to make it able to deal with the HTML that is actually "out there", and it normally parses as closely as possible to the way the popular web browsers do it instead of strictly following one of the many HTML specifications from W3C. Where there is disagreement, there is often an option that you can enable to get the official behaviour."

    But I have yet to see a browser that will treat <bold_text> as a tag, rather than simply ignoring it (and merely rendering the enclosed text without additional formatting.

    Update: The doc does -- again, to me and YMMV -- suggest that you could tweak your script to deal with some of the invalid tag-like entries:

    $p->strict_names
    $p->strict_names( $bool )
    By default, almost anything is allowed in tag and attribute names. This is the behaviour of most popular browsers and allows us to parse some broken tags with invalid attribute values like:

    <IMG SRC=newprevlstGr.gif ALT=PREV LIST BORDER=0>

    By default, "LIST]" is parsed as a boolean attribute, not as part of the ALT value as was clearly intended. This is also what Mozilla sees.

    The official behaviour is enabled by enabling this attribute. If enabled, it will cause the tag above to be reported as text since "LIST]" is not a legal attribute name.

    "What may be possible" and "what's provided by this node" are -- however -- two different things. :-\

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://881071]
help
Chatterbox?
[shmem]: no. You're right.
[msh210]: About time... last time I was right was... I don't even remember when.
[shmem]: perl -e 'warn "test$/", ^@^ '
[Eily]: well, at least it's right about warn doing the same thing as die :)
[shmem]: same with undef as last element
[msh210]: oh, good point. It's the best kind of correct
[shmem]: msh210: but I'd not call it a lie outright. That's when you do know the truth.
[msh210]: I don't have sendmail (I'm on MS Windows), so does one of you think you can report the bug?
[shmem]: msh210: 'tis about time to tell the sad truth to perl5porters - via perlbug
[msh210]: probably whoever wrote that actually knows the truth

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (16)
As of 2017-04-24 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.