title: Writing xml content with comma ',' to csv
body: <p>My csv file is a comma delimited file. I need to write XML contained in a variable to last cell of each row as part of my requirement. This XML contains <code>commas(')</code> which when written through CSVWriter, writes incorrectly. each comma is treated as delimiter and the XML is split into different cells.</p>
  
  <p>Part of my xml as sample </p>
  
  <pre><code>&lt;tns:Nature&gt;Residential&lt;/tns:Nature&gt;
  &lt;tns:Type&gt;Duplex&lt;/tns:Type&gt;
  &lt;tns:OccupancyPurpose&gt;Owner Occupied Primary Residence&lt;/tns:OccupancyPurpose&gt;
  &lt;tns:Valuation&gt;
  &lt;tns:Sequence&gt;1&lt;/tns:Sequence&gt;
  &lt;tns:ValuationAmount&gt;700000&lt;/tns:ValuationAmount&gt;
  &lt;tns:ValuationDate&gt;2014-08-13&lt;/tns:ValuationDate&gt;
  &lt;tns:ValuerCompany&gt;C J A **Replace_Comma** Lee **Replace_Comma** Property&lt;/tns:ValuerCompany&gt;
  &lt;tns:ValuationType&gt;Electronic Assessment&lt;/tns:ValuationType&gt;
  &lt;/tns:Valuation&gt;
  </code></pre>
  
  <p>My code goes as below.</p>
  
  <pre><code>    strLine = strLine + strXMLContent;
      File file = new File(strFilePath); 
  
          FileWriter outputfile = null;
          try 
          {
              outputfile = new FileWriter(file,true);
              CSVWriter writer = new CSVWriter(outputfile,',', CSVWriter.NO_QUOTE_CHARACTER,CSVWriter.DEFAULT_ESCAPE_CHARACTER,System.getProperty("line.separator"));;
  
              String arr[] = strLine.split(",",-1);
              for(int i = 0;  i&lt; arr.length; i++)
              {
                  arr[i] = arr[i].replace("Replace_Comma", ","); //Replaces filler as a comma before being placed in csv
              }
              writer.writeNext(arr);
              writer.close();
          } 
          catch (IOException e) 
          {
              e.printStackTrace();
          } 
  </code></pre>
  
  <p>The filler when translated as a comma is treated as a delimiter and the following text is written in the next cell. </p>
  
  <p>I have tried many things but to no avail. Please help.</p>