NodeSet slicing returns wrong/inconsistent results
According to the documentation, slicing a NodeSet should return an Oga::XML::Node.
When I try slice a NodeSet on two XML files that are identical except for pretty formatting, it returns either an Oga::XML::Text or an Oga::XML::Element.
Here's a simple script to reproduce:
require 'oga'
xpath = "/HPXML/Building/BuildingDetails/Enclosure/Walls/Wall/WallType"
xml1 = File.join(File.dirname(__FILE__),'test1.xml')
doc = Oga.parse_xml(File.read(xml1))
puts "test1.xml children: #{doc.at_xpath(xpath).children}"
puts "test1.xml child0: #{doc.at_xpath(xpath).children[0]}"
puts "test1.xml child1: #{doc.at_xpath(xpath).children[1]}"
xml2 = File.join(File.dirname(__FILE__),'test2.xml')
doc = Oga.parse_xml(File.read(xml2))
puts "test2.xml children: #{doc.at_xpath(xpath).children}"
puts "test2.xml child0: #{doc.at_xpath(xpath).children[0]}"
puts "test2.xml child1: #{doc.at_xpath(xpath).children[1]}"
This produces the following output:
test1.xml children: #<Oga::XML::NodeSet:0x0000016e98396dd8>
test1.xml child0: #<Oga::XML::Text:0x0000016e98397418>
test1.xml child1: #<Oga::XML::Element:0x0000016e98397238>
test2.xml children: #<Oga::XML::NodeSet:0x0000016e97cb3098>
test2.xml child0: #<Oga::XML::Element:0x0000016e97cb3430>
test2.xml child1:
I would expect test1.xml and test2.xml to A) give identical results and B) only ever return an Oga::XML::Node (or nil).