Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2022-12-07 15:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found