mbklein / equivalent-xml

Easy equivalency tests for Nokogiri and Oga XML
MIT License
94 stars 29 forks source link

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

Open mirelon opened 10 years ago

mirelon commented 10 years ago

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

mirelon commented 10 years ago

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 commented 10 years ago

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()