Skip to content

xml2 is not removing namespaced attributes #387

Description

@cole-johanson

Possibly related to 340.

The xml2 Node Modification vignette states that using NULL as the value will remove the attribute completely. In the example below, the 'space' attribute in doc1 is correctly removed using this method. However, the 'xml:space' attribute in doc2 is not getting removed using this method.

library(xml2)
doc1 = as_xml_document('<xml><t space="preserve">1</t><t space="preserve">2</t></xml>')
doc1_children = xml_children(doc1)
xml_attrs(doc1_children) <- NULL
print(doc1_children)
#> {xml_nodeset (2)}
#> [1] <t>1</t>
#> [2] <t>2</t>

doc2 = as_xml_document('<xml><t xml:space="preserve">1</t><t xml:space="preserve">2</t></xml>')
doc2_children = xml_children(doc2)
xml_attrs(doc2_children) <- NULL
print(doc2_children)
#> {xml_nodeset (2)}
#> [1] <t xml:space="preserve">1</t>
#> [2] <t xml:space="preserve">2</t>

Created on 2023-04-24 with reprex v2.0.2

Activity

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

    bugan unexpected problem or unintended behaviornamespace 📛

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions