Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Comparing HTML snippets

by chrestomanci (Priest)
on Mar 02, 2014 at 17:08 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-19 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found