Forum Discussion
You should know that replace() or replaceAll() method takes only 2 arguments within quotes like this :- replace("", "") This is not the correct way of using this method :- replace(/*,"\\s+", "") and by the way, what is your input String and what is your expected output?
@ashutoshanshu wrote:...and by the way, what is your input String and what is your expected output?
I have a lot of properties, containing xml parts (with linebreaks) and I want to linearize them for using in a *.csv file.And save csv with aditionally linebreaks are ... :smileymad:
And because all of my tries with xpath and xqerry were unsucsessfully, I trieed it now with a grovy script.
- shamane20008 years agoOccasional Contributor
for example:
<node> test1 <subnode> test2 </subnode> test3 </node>
what I want is:
<node>test1<subnode>test2</subnode>test3</node>
Thanks in advance,
Shamane2000
Oh, for this kind of stuff. You need to think for another approach. Please go through this code:-
BufferedReader br = new BufferedReader(new FileReader(new File("C:\\Users\\ASHUTOSH\\Desktop\\newXml.xml"))); String line; StringBuilder sb = new StringBuilder(); while((line=br.readLine())!= null){ sb.append(line.trim()); } log.info sb
Here, newXml.xml file contains your xml data. And once you run it. You will get this result:-
Tue Feb 20 23:18:58 IST 2018:INFO:<node>test1<subnode>test2</subnode>test3</node>