Reputation: 47
I tried to write xml tags by using BufferWriterBut,when i am trying to open a file it is displaying like empty page.The code is like below
bw.write("<?xml version=" + "\"1.0\"" + " " + "encoding=" + "\"UTF-8\""
+ "?>");
bw.newLine();
bw.write("<con:soapui-project activeEnvironment=" + "\"Default\"" + " "
+ " name=" + "\"REST Project 1\"" + " " + "soapui-version="
+ "\"4.6.4\"" + " " + "xmlns:con="
+ "\"http://eviware.com/soapui/config\"" + ">");
bw.newLine();
bw.write("<con:settings/>");
bw.newLine();
bw.write("<con:interface xsi:type=" + "\"con:RestService\"" + " "
+ "wadlVersion=" + "\"http://wadl.dev.java.net/2009/02\"" + " "
+ "name=" + "\"" + baseUrl1 + "\"" + "" + " " + "type="
+ "\"rest\"" + " " + "xmlns:xsi="
+ "\"http://www.w3.org/2001/XMLSchema-instance\"" + ">");
bw.newLine();
bw.write("<con:settings/>");
Can i write the xml tags like above or is there any way to write xml tags
Upvotes: 0
Views: 976
Reputation: 1
Use Documentbuilder Class instead. It has Element interface which can be used to write xml tags more efficiently.
Upvotes: 0
Reputation: 5314
Why reinvent the wheel? You could use JAXB and search for marshalling
.
For starters you could refer to this.
Upvotes: 2
Reputation: 653
If JAXB is to difficult for you, try the DOM Parser. Its pretty simple.
Upvotes: 0
Reputation: 328724
A BufferWriter
, as the name implies, has a buffer and it will only flush the buffer to the file when one of three conditions are met:
flush()
None of them apply in your case, so the file stays empty.
Upvotes: 1