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

Node attributes printed on close tag #113

Closed
gregmacfarlane opened this issue Jul 20, 2016 · 2 comments
Closed

Node attributes printed on close tag #113

gregmacfarlane opened this issue Jul 20, 2016 · 2 comments

Comments

@gregmacfarlane
Copy link

If I add an attribute to a tag, then the attribute is also printed when the tag is closed.

script <- xml2::xml_new_document() %>%
  xml2::xml_add_child("osm-script")
union <- xml2::xml_add_child(script, 'union into="_"')
query <- xml2::xml_add_child(union, 'query type="way"')
script
## {xml_document}
## <osm-script>
## [1] <union into="_">\n  <query type="way"/>\n</union into="_">

This seems to violate xml syntax, e.g. in the wikipedia example

<step number="3">Connect A to B.</step>

Am I mistaken? Is there a way to turn off this behavior?

*Note this stackoverflow question

@jimhester
Copy link
Member

Your single quotes seem to be in the wrong place, which is causing the 'attributes' to be treated as text nodes.

script <- xml2::xml_new_document() %>%
  xml2::xml_add_child("osm-script")
union <- xml2::xml_add_child(script, "union", into = "_")
query <- xml2::xml_add_child(union, "query", type = "way")
script
#> {xml_document}
#> <osm-script>
#> [1] <union into="_">\n  <query type="way"/>\n</union>

@gregmacfarlane
Copy link
Author

Ah, I've got it. So the tag name and the attributes should come separately. Too clever for me to see immediately, but I've got it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants