Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV to XML

Status
Not open for further replies.

jencinas69

Programmer
May 15, 2008
3
US
Hello I have to conver a CSV file to an XML file, I never done this before. Any one have had experience with CSV to XML?

here is a link to my csv file

media.yumasun.com/xml/csv.php

Thank you

Joaquin Encinas
 
It is a parsed csv file that I need to convert to XML. Do you know a way to do it?

Thank you

 
CSV are just a bunch of values separated by commas. To convert it to XML first you need to define tags, so there's no way to help you without more details.

Cheers,
Dian
 
This is the tags I need

<ad adID="12345"
-
startingPrice="27995.00"
-
>
<title>
<![CDATA[2005 Toyota Truck $27,000]]>
</title>
<description>
<![CDATA[12,594 miles, $400/month]]>
</description>

But I need something that converts the csv into this dinamicaly


 
Since you've already got a parser (more or less), you simply need to add the appropriate tag to each output line instead of just writing the variable. If you're parsing with a loop in your php file, just make an array of the tag text.

I suspect there's a small problem with either your parser or your data in this area of your file:
Code:
CERTIFIED LIFEGUARD Seasonal, 30-40 hours/week, non-exempt, not-eligible -for-benefits position OPENS:


May 2, 2008 CLOSES:
since the closing date doesn't show up.
 
if you are using php you might want to read the info on the fgetcsv function:


there s some very good examples on how to loop trough an csv file

while looping trough the csv file you could use the simplexml (buildin) class or the safox class (sourceforge) to write to your xml file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top