I am creating an xml in shiny app. How to add TAGS in xml from NEXT LINE.

Creating an xml in shiny app using xml package

library(shiny)

ui <- fluidPage(

actionButton("OK","OK"),
textOutput("XML")

)
library(shiny)
library(xml)

server <- function(input, output, session) {
  
  observeEvent(input$OK,{

      xml <- xmlTree()
      
     xml$addTag("MAIN",attrs = c("id"="TO_FILL",
                                "VARIABLE1"="true",
                                "VARIABLE2"="TO_FILL",
                                "VARIABLE3" = "INTEGER",close=F)
      
     xml$addTag("Time",close=F)
     xml$addTag("LOGGED",attrs=c("id"="TO_FILL"),close=F)
     xml$addTag("timelog",.children = paste0(Sys.time()))
#......………. More tags to be added
      
output$XML <- renderText({saveXML(xml)})

}

}

output I am getting is

<?xml version="1.0"?> <MAIN id="TO_FILL" VARIABLE1="true" VARIABLE2="TO_FILL" VARIABLE3="INTEGER"> <Time> <LOGGED id="TO_FILL"> <timelog>2019-12-27 12:34:12</timelog> </LOGGED> </Time> </MAIN>

How can I enter tags in new line like this,

<?xml version="1.0"?> <MAIN id="TO_FILL" VARIABLE1="true" VARIABLE2="TO_FILL" VARIABLE3="INTEGER">
 <Time> 
<LOGGED id="TO_FILL">
 <timelog>2019-12-27 12:34:12</timelog>
 </LOGGED> 
</Time> 
</MAIN>

Thank You for your time.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.