xml2
xml2 copied to clipboard
xml_set_attrs removes namespace
Hi team
I'm using xml2::xml_set_attrs to modify an xml us the following
# read xml from some file
xmlparent <- read_xml(XML_Input_Template_Path)
# find a specific path and add attributes to elements
xmlparent %>% xml_find_all(., xpath = ".//d1:command[@fragment='paramModelDate']/r:paramInstance") %>%
xml_set_attrs(., c("xsi:type" = "FdbModelDate", "date" = as.character(as.Date(FDBDate, format = "%Y%m%d")), "model" = FDBModel, "repository" = FDB_Path))
Initialy my xml was lilke this:
After using xml_set_attrs the attributes are correctly modified but the namespace had been removed. How can I force it here ?
Thanks
adding xml files
Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you! If you've never heard of a reprex before, start by reading about the reprex package, including the advice further down the page. Please make sure your reprex is created with the reprex package as it gives nicely formatted output and avoids a number of common pitfalls.
I've closed this issue due to lack of requested reprex. If you still care about this bug, please open a new issue with a reprex.