Skip to content

XMLDecl mixed in xpath descendant::node() match result #331

Closed

Description

@tompng

XMLDecl should be excluded

# Expected
Nokogiri::XML.parse('<?xml version="1.0"?><root></root>').xpath("descendant::node()")
# => [#<Nokogiri::XML::Element:0xb38 name="root">]

# Actual
REXML::XPath.match REXML::Document.new('<?xml version="1.0"?><root></root>'), "descendant::node()"
# => [<?xml ... ?>, <root/>]
REXML::VERSION
# => "3.4.4"

Activity

  1. tompng commented on Jun 28, 2026

    @tompng
    MemberAuthor

    After #315, optimizable descendant doesn't have this problem any more.

    REXML::XPath.match REXML::Document.new('<?xml version="1.0"?><root></root>'), "descendant::node()"
    # => [<root/>]

    But still not fixed for unoptimizable descendant xpath

    REXML::XPath.match REXML::Document.new('<?xml version="1.0"?><root></root>'), "descendant::node()[position()*0!=42]"
    # => [<?xml ... ?>, <root/>]
  2. added a commit that references this issue on Jul 11, 2026
    73aa07a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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