Trying to edit the value of maxTreeAgeInit="50.0" in an xml file (outline as follows)
middle of my xml file (xml version="1.0" encoding="utf-8") of interest:
<InitTreeF treeExistsInit="true" maxTreeAgeInit="50.0" avgTreeAgeInit="50.0" tInitStem="Frac" stemMInitF="" branMInitF="" barkMInitF="" leafMInitF="" cortMInitF="" firtMInitF="" stemVolInitF="" stemFracInitF="0.422069892" branFracInitF="0.199533585" barkFracInitF="0.113706229" leafFracInitF="0.059503198" cortFracInitF="0.17649553" firtFracInitF="0.028691566" stemNCRatioInitF="" branNCRatioInitF="" barkNCRatioInitF="" leafNCRatioInitF="" cortNCRatioInitF="" firtNCRatioInitF="" storNMInitF="" stemM3PGInit="" foliM3PGInit="" rootM3PGInit="" nStemsInit="" frFracInit="1.0" tFrFracInit="FracConst" treeNmInit="Eucalyptus Tall Open Forest" agRegimeId="943207214" />
z <- c("InitTreeF treeExistsInit="true" maxTreeAgeInit="50.0"")
y <- c("InitTreeF treeExistsInit="true" maxTreeAgeInit="60.0"")
xml_1 <- str_replace(stri_read_lines("Southern_NSW_prescribed_1000yr.plo"), z, y)
The R script I am using flags errors e.g. for z : 'unexpected token 'true', unexpected token '50.0'
BIG PICTURE: I wish to modify the xml file parameter values, which is input into an external cmd model.bat I call from a batch file in windows, so I can run the model.bat multiple times with different parameter values.
The R script I am using (below) flags errors e.g. for z : 'unexpected token 'true', unexpected token '50.0'
z <- c("InitTreeF treeExistsInit="true" maxTreeAgeInit="50.0"")
y <- c("InitTreeF treeExistsInit="true" maxTreeAgeInit="60.0"")
xml_1 <- str_replace(stri_read_lines("Southern_NSW_prescribed_1000yr.plo"), z, y)
I'm thinking that I need to escape 'true' and '50' to read the line from the xml file in as text string and then the rest of the R script should work... as it does work on text file with simple text without ="true" or ="50" in it.