write xml from java file
<p>My code have some errors on building xml structure. Can someone troubleshoot this code?</p>

<pre><code>    public class tulis{
        public static void main(String[] args)throws IOException{


        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("markers3.xml"));


       sql_connection msconn=new sql_connection();
       msconn.connect("gfsat", "root", "");
       ResultSet rs=msconn.selectQuery("*", "location");
      if(rs!=null)
      {
                try
                {
                    while (rs.next())
                    {


       bufferedWriter.write("&lt;marker lat = \""+rs.getString(1)+ "\" lng = \"" +rs.getString(2)+ "\" \nhtml = 'Fish name:"+rs.getString(3)+"&amp;lt;br&amp;gt;Stock:"+rs.getString(4)+"tan metrik&amp;lt;br&amp;gt;Fish length"+rs.getString(5)+"cm&amp;lt;br&amp;gt;Status:"
                                     +rs.getString(6)+ "&amp;lt;br&amp;gt;"+ "\n label = \""+rs.getString(7)+"\"\n/&gt;");


        bufferedWriter.newLine();
              }
                } catch (SQLException ex){
                    ex.printStackTrace();

        }
        msconn.disConnect();

        bufferedWriter.flush();
        bufferedWriter.close();
        }
    }
    }
</code></pre>

<p>and here's the xml structure produce from above code..</p>

<pre><code>    &lt;marker lat = "6.22353" lng = "102.111" 
    html = 'Fish name:ikan cencaru&amp;lt;br&amp;gt;Stock:1495.63343tan metrik&amp;lt;br&amp;gt;Fish length12cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Geting"
    /&gt;
    &lt;marker lat = "5.90101" lng = "102.565" 
    html = 'Fish name:ikan bawal&amp;lt;br&amp;gt;Stock:1000tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Kuala Besar"
    /&gt;
    &lt;marker lat = "5.83095" lng = "102.563" 
    html = 'Fish name:ikan cermin/sagai/cupak&amp;lt;br&amp;gt;Stock:399.92534tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Kuala Besut"
    /&gt;
    &lt;marker lat = "5.32289" lng = "103.132" 
    html = 'Fish name:ikan kembung&amp;lt;br&amp;gt;Stock:10104.3163tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Pulau Kambing"
    /&gt;
    &lt;marker lat = "5.31688" lng = "103.171" 
    html = 'Fish name:ikan siakap&amp;lt;br&amp;gt;Stock:3.49643tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Chendering"
    /&gt;
    &lt;marker lat = "5.16911" lng = "103.229" 
    html = 'Fish name:ikan merah&amp;lt;br&amp;gt;Stock:266.25693tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Marang"
    /&gt;
    &lt;marker lat = "4.77798" lng = "103.425" 
    html = 'Fish name:ikan kerapu&amp;lt;br&amp;gt;Stock:369.48534tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Dungun"
    /&gt;
    &lt;marker lat = "4.24039" lng = "103.445" 
    html = 'Fish name:ikan parang&amp;lt;br&amp;gt;Stock:491.26436tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Kemaman"
    /&gt;
    &lt;marker lat = "3.79516" lng = "103.317" 
    html = 'Fish name:ikan jenahak&amp;lt;br&amp;gt;Stock:1000tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Kuantan"
    /&gt;
    &lt;marker lat = "3.53455" lng = "103.462" 
    html = 'Fish name:ikan duri&amp;lt;br&amp;gt;Stock:1000tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Kuala Pahang"
    /&gt;
    &lt;marker lat = "2.80024" lng = "103.487" 
    html = 'Fish name:ikan kembung&amp;lt;br&amp;gt;Stock:289.35158tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Kuala Rompin"
    /&gt;
    &lt;marker lat = "2.54508" lng = "103.66" 
    html = 'Fish name:ikan gelama/sengkerang&amp;lt;br&amp;gt;Stock:4826.84247tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Endau"
    /&gt;
    &lt;marker lat = "2.43594" lng = "103.836" 
    html = 'Fish name:ikan selar kuning&amp;lt;br&amp;gt;Stock:2940.80957tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Mersing"
    /&gt;
    &lt;marker lat = "1.34282" lng = "104.142" 
    html = 'Fish name:ikan selar&amp;lt;br&amp;gt;Stock:3372.49406tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Sedili"
    /&gt;
    &lt;marker lat = "2.38631" lng = "101.971" 
    html = 'Fish name:ikan selayang&amp;lt;br&amp;gt;Stock:1000tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Kuala Linggi"
    /&gt;
    &lt;marker lat = "3.00533" lng = "101.413" 
    html = 'Fish name:ikan kerisi bali&amp;lt;br&amp;gt;Stock:200.76684tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Pelabuhan Klang"
    /&gt;
    &lt;marker lat = "4.2111" lng = "100.641" 
    html = 'Fish name:ikan kerapu&amp;lt;br&amp;gt;Stock:969.48534tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Lumut"
    /&gt;
    &lt;marker lat = "5.68194" lng = "100.371" 
    html = 'Fish name:ikan siakap&amp;lt;br&amp;gt;Stock:3.49643tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Tanjung Dawai"
    /&gt;
    &lt;marker lat = "5.81496" lng = "100.371" 
    html = 'Fish name:ikan bawal&amp;lt;br&amp;gt;Stock:1000tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Sungai Udang"
    /&gt;
    &lt;marker lat = "5.41594" lng = "100.365" 
    html = 'Fish name:ikan selayang&amp;lt;br&amp;gt;Stock:10104.3163tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Batu Maung"
    /&gt;
    &lt;marker lat = "6.40548" lng = "100.414" 
    html = 'Fish name:ikan jenahak&amp;lt;br&amp;gt;Stock:1000tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Kuala Perlis"
    /&gt;
    &lt;marker lat = "1.57747" lng = "110.377" 
    html = 'Fish name:ikan bawal putih&amp;lt;br&amp;gt;Stock:4.92942tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Bintawa"
    /&gt;
    &lt;marker lat = "2.30282" lng = "111.273" 
    html = 'Fish name:ikan bawal hitam&amp;lt;br&amp;gt;Stock:1000tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Belawai"
    /&gt;
    &lt;marker lat = "2.50686" lng = "112.316" 
    html = 'Fish name:ikan gelama/tengkerong&amp;lt;br&amp;gt;Stock:289.35158tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Mukah"
    /&gt;
    &lt;marker lat = "2.225" lng = "111.335" 
    html = 'Fish name:ikan kerisi&amp;lt;br&amp;gt;Stock:5831.09568tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Tanjung Manis"
    /&gt;
    &lt;marker lat = "3.19783" lng = "113.091" 
    html = 'Fish name:ikan lolong&amp;lt;br&amp;gt;Stock:3735.66249tan metrik&amp;lt;br&amp;gt;Fish length8cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Bintulu"
    /&gt;
    &lt;marker lat = "4.33737" lng = "113.995" 
    html = 'Fish name:ikan pelaling/temenong&amp;lt;br&amp;gt;Stock:34.42008tan metrik&amp;lt;br&amp;gt;Fish length13cm&amp;lt;br&amp;gt;Status:matured&amp;lt;br&amp;gt;
    label = "LKIM Miri"
    /&gt;
</code></pre>
