Skip to content

xml_length() on empty nodeset #404

@mgirlich

Description

@mgirlich

xml_length(xml_nodeset()) returns 0 but I feel this should rather be integer() which would also be consistent with e.g. xml_name().

library(xml2)

(ns1 <- xml2:::xml_nodeset())
#> {xml_nodeset (0)}
xml_length(ns1)
#> [1] 0
(ns2 <- xml2:::xml_nodeset(list(xml_missing()), deduplicate = FALSE))
#> {xml_nodeset (1)}
#> [1] <NA>
xml_length(ns2)
#> [1] 0

Created on 2023-08-29 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions