[libxml-devel] Changing node equality
Sean Chittenden
sean at chittenden.org
Wed Jul 9 16:07:43 EDT 2008
>> Not the same thing. Comparing raw XML string is overly strict. For
>> example I would expect the following two snips to be "equal":
>
> <root><foo bar="10" baz="20">Hi</foo></root
>
> and
>
> <root>
> <foo baz="20" bar="10">
> Hi
> </foo>
> </root>
>
> These would not be equal by string comparison b/c the attribute bar
> and baz are not in the same order (to say nothing of white space).
Actually, they're not equal for a different reasons. You have to
enable whitespace stripping on document load, then they would be
correct. Internally, XML sees the above fragment like:
<root>[whitespace, including newline]<foo baz="20" bar="10">
Hi
</foo>[whitespace, including newline]</root>
Whitespace is a special XML node that exists between elements. <:~/
Not ideal, and not something I agree with, but...
--
Sean Chittenden
sean at chittenden.org
More information about the libxml-devel
mailing list