Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml2 is not removing namespaced attributes #387

Open
cole-johanson opened this issue Apr 24, 2023 · 0 comments
Open

xml2 is not removing namespaced attributes #387

cole-johanson opened this issue Apr 24, 2023 · 0 comments
Labels
bug an unexpected problem or unintended behavior namespace 📛

Comments

@cole-johanson
Copy link

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

@hadley hadley added bug an unexpected problem or unintended behavior namespace 📛 labels Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior namespace 📛
Projects
None yet
Development

No branches or pull requests

2 participants