equivalent-xml icon indicating copy to clipboard operation
equivalent-xml copied to clipboard

Added test "It is able to ignore nodes with xmlns attribute set"

Open mirelon opened this issue 11 years ago • 2 comments

When I compare two nodes which have set "xmlns" attribute, and ignoring them, they should be equal.

mirelon avatar Feb 05 '14 14:02 mirelon

This bug may relate to line path = path.gsub(/xmlns:/, ' :') unless Nokogiri.uses_libxml? in https://github.com/sparklemotion/nokogiri/blob/master/lib/nokogiri/xml/node.rb#L153

In the console, when I run:

> Nokogiri::XML('<a xmlns=""></a>').xpath("a")
=> [#<Nokogiri::XML::Element:0x385e name="a">]

but:

> Nokogiri::XML('<a xmlns=""></a>').css("a")
Nokogiri::XML::XPath::SyntaxError: // :a
from nokogiri/XmlXpathContext.java:123:in `evaluate'

The css method is called at https://github.com/mbklein/equivalent-xml/blob/master/lib/equivalent-xml.rb#L188

mirelon avatar Feb 05 '14 15:02 mirelon

It is a nokogiri bug, but it would be nice if ignoring_content_of() allowed also xpath queries. I propose using search() instead of css()

mirelon avatar Feb 06 '14 09:02 mirelon