[libxml-devel] Changing node equality

Charlie Savage cfis at savagexi.com
Tue Jul 8 14:37:05 EDT 2008



Trans wrote:
> 
> On Jul 8, 12:04 pm, Charlie Savage <c... at savagexi.com> wrote:
>>> Hmmm... How does the C library itself handle comparison?
>> Well, in C the == is identity (comparing pointer addresses).  libxml
>> does not provide an equality method that I see.
> 
> So there is no way to compare on content, only identity. 

Well, its easy enough:

if node1.to_s == node2.to_s

Or

if node1.content == node2.content

to_s is like outerHTML and content is innerHTML (sort of).

But is that
> good for Ruby too? I wonder how changing #== to identity might effect
> current users? 

Best guess it gives them a nice performance boost, since I'm not seeing 
how comparing on content is useful

Even so, I agree that comparing raw xml strings doesn't
> makes sense, but comparing equivalence, as opposed to identity, can be
> useful, ie. same tag names, same attributes (irregardless of order)
> and same data. 

See above.

Otherwise it would seem like we are suggesting that XML
> nodes should be immutable.

Hmm, why do you say that?

Charlie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://rubyforge.org/pipermail/libxml-devel/attachments/20080708/d364c825/attachment.bin>


More information about the libxml-devel mailing list