posted 6 years ago
I want to get xml content then update it and send it back to it's original place, but evry time i run my code it seems that extra characters are added ('\r' and '\n') with this updated data and as a result it increases file size , how can i remove this characters? When i try to update my xml at first time it changes xml tag values but on the other attempts it neither trows exception nor updates data, is it because that this '\n' are changing position xml tag values? :
[code=groovy]def xml = new XmlParser().parseText(content)
for(int i=0;i<value.size();i++) {
date = value.get(i).substring(0, 10);
xml.Mr.ross.details.findAll( { p ->
p.runAs[0].text() == "true" && date.toString()== p.start[0].text();
}).each({ p ->
p.start[0].value =addDays( p.start[0].text())
p.runAs[0].value ="true"
})
}
For example xml data looks like:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><service>
<Ms>
<ross>
<details>
<start>
2017-09-07
</start>
<startDate>
2017-02-02
</startDate>
<endDate>
2017-03-02
</endDate>
<runAs>
true
</runAs>
<makeVersion>
1
</makeVersion>
<patch>
this is patch
</patch>
<parameter>
1
</parameter>
</details>
</ross>
</Ms>
</service>