Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2024-04-23 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found