--0050450140c41cf982048b889250
Content-Type: text/plain; charset=UTF-8

On Sat, Jul 17, 2010 at 12:28 AM, Xeno Campanoli / Eskimo North and Gmail <
xeno.campanoli / gmail.com> wrote:

> I'm looking through what documentation I can find for Hpricot (nokogirl
> wouldn't install for me, and I just wand a quick an simple solution), and I
> cannot find a simple method to take two xml strings and find out if they are
> equivalent.  I'm getting a bunch of xhmtl back from our rendering agent with
> random permutations of attributes inside of the tags, and I want a quick and
> easy ruby way to find out of segments are equivalent without writing my own
> regex based parser...???


I can think of a few definitions for equivalence. One definition would
simply require unifying the case of both strings and checking if they are
the same. A second definition would require building a tree of the structure
in each string, including attributes, sorting it, and looping over them to
check if they contain the same elements (Nokogiri's XML::NodeSet does
something like this with . A third definition would build on the second
one, while treating certain tags as equivalent to other tags (for example q
is equivalent to blockquote).

What's *your* definition of equivalence for two xml documents or fragments?

Ammar

--0050450140c41cf982048b889250--