I have an
rdocx and I want to manipulate something in the xml code. That’s my document:
library(officer) doc <- read_docx() %>% body_add_par("centered text", style = "centered") %>% slip_in_seqfield("STYLEREF 1 \\s") %>% slip_in_text("\u2011") %>% slip_in_seqfield(sprintf("SEQ %s \\* ARABIC \\s 1", "Table")) %>% slip_in_text(str_c(": ", "My Caption")) %>% body_bookmark("my_bookmark")
doc$doc_obj$get() I can get the xml code with classes
xml_node. Now I want to replace some code, in detail I want the part with
w:bookmarkEnd to appear later so the bookmarked part gets bigger. How can I achieve this? If I could achieve this with
str_replace it would be awesome.
Leave an answer