Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Comparing HTML snippets

by chrestomanci (Priest)
on Mar 02, 2014 at 17:08 UTC ( #1076720=note: print w/ replies, xml ) Need Help??


in reply to Comparing HTML snippets

HTML::TreeBuilder creates a very complex doubly linked tree. Very useful if you want to parse HTML, and walk between nodes in the parse tree, but less helpful if you are trying to find differences between two bits of HTML.

If you have two bits of HTML that are identical except for white-space (capitalisation, etc), then HTML::TreeBuilder should return identical trees for them, but there is a slight difference, then I think you will find it hard to find the difference by comparing the trees. For example if you use is_deeply out of Test::More it will find an enormous number of differences and then show you the first one it finds that is unlikely to be helpful to your problem.

Perhaps a better solution would be to not use perl, and instead pipe your HTML samples through a tool like html-tidy and then do a text diff of the output.


Comment on Re: Comparing HTML snippets
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1076720]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-09-30 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (381 votes), past polls