Skip to content

Functions or expressions raises exception in chained xpath call #656

Closed
@Fitzsimmons

Description

I think this test really says it all.

require 'rubygems'
require 'nokogiri'

fail_xml = <<-XML
<root>
  <stuff>thing</stuff>
</root>
XML

fail_doc = Nokogiri::XML(fail_xml)

puts fail_doc.xpath("//root").xpath("./stuff/text()").inspect #works
puts fail_doc.xpath("//root/stuff/text() = 'thing'").inspect #works
puts fail_doc.xpath("//root").xpath("./stuff/text() = 'thing'").inspect #crashes

Stacktrace:

/home/justinf/.rvm/gems/ruby-1.9.3-p0/gems/nokogiri-1.5.2/lib/nokogiri/xml/node_set.rb:135:in `|': node_set must be a Nokogiri::XML::NodeSet (ArgumentError)
    from /home/justinf/.rvm/gems/ruby-1.9.3-p0/gems/nokogiri-1.5.2/lib/nokogiri/xml/node_set.rb:135:in `block in xpath'
    from /home/justinf/.rvm/gems/ruby-1.9.3-p0/gems/nokogiri-1.5.2/lib/nokogiri/xml/node_set.rb:239:in `block in each'
    from /home/justinf/.rvm/gems/ruby-1.9.3-p0/gems/nokogiri-1.5.2/lib/nokogiri/xml/node_set.rb:238:in `upto'
    from /home/justinf/.rvm/gems/ruby-1.9.3-p0/gems/nokogiri-1.5.2/lib/nokogiri/xml/node_set.rb:238:in `each'
    from /home/justinf/.rvm/gems/ruby-1.9.3-p0/gems/nokogiri-1.5.2/lib/nokogiri/xml/node_set.rb:134:in `xpath'
    from test_constraint.rb:14:in `<main>'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions