Dear All, Firstly, just to let you know I know nothing of PERL but I've inherited a small script which essentially converts an CSV file into a XML file. This XML file is then parsed by our VoIP phones as a phone directory. We have a new brand of phones which parses double quotes from the XML file where others do not. Below is the code that is generating the XML:
#!/usr/bin/perl -w #fn - First Name #ct - Extension #use strict ; #use warnings ; #Name if the File that contains the User Direcotry Data open (FILE, 'phonelist.csv') || die("Could not open the input file dir +ectory.csv!\n"); #create if not yet created and/or overwrite existing directory-0000000 +00000.xml open (OUTPUTFILE, ">000000000000-directory.xml") || die("Could not ope +n/create the output file directory-000000000000.xml!\n"); #below section contains the standard [general] header of the sip.conf print OUTPUTFILE "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone= +\"yes\"?>\n"; print OUTPUTFILE "<directory>\n"; print OUTPUTFILE "\t<item_list>\n"; while (<FILE>) { chomp; ################################################################### #we are splitting the comma seperated values into the single Items# #add additional $columnX to accomodate further entries# ################################################################### ($column1,$column2,) = split(','); print OUTPUTFILE "\t\t<item>\n"; print OUTPUTFILE "\t\t\t<fn>$column1</fn>\n"; print OUTPUTFILE "\t\t\t<ct>$column2</ct>\n"; print OUTPUTFILE "\t\t</item>\n"; } print OUTPUTFILE "\t</item_list>\n"; print OUTPUTFILE "</directory>\n"; #close the csv example file close (FILE); #close the modified sip.conf file close (OUTPUTFILE); exit;
The source CSV file has quotes around the string in column 1 which I cannot change. I need a way for the above script to remove or ignore double quotes.. even snipping a character from the beginning and end would do. Any help appreciated. Cheers, Jake

In reply to Remove Double Quotes from XML Output by JakeBloomfield

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.