Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 30-10-07
mike_01's Avatar
Life's changing...
 
Join Date: Nov 2005
Location: Planet_Zumbi
Posts: 295
Thanks: 4
Thanked 1 Time in 1 Post
mike_01 is an unknown quantity at this point
  Excel to XML converter

Hiya,

I am looking for the script or a program that i can run on local to convert the excel spreadsheet to xml sheet. Tried googling too but couldn't find the right one available. There are few offering the demo version too but that generates the xml sheet with the "Please buy licence" code.

Does anyone here got a script or program for the same?

P.S - I am looking for the "FREE" script as of now

Thanks,
Mike...
__________________
"Falling down is not Defeat....Defeat is when you refuse to get up."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 30-10-07
Registered User
 
Join Date: Nov 2003
Location: London
Posts: 524
Thanks: 0
Thanked 4 Times in 4 Posts
moredial is an unknown quantity at this point
  Re: Excel to XML converter

The free script

1/ convert excel to csv format

2/ use php (or other) script to parse the csv file to xml format

If it is a big set of data, the quicker option is to parse to an sql database.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 30-10-07
mike_01's Avatar
Life's changing...
 
Join Date: Nov 2005
Location: Planet_Zumbi
Posts: 295
Thanks: 4
Thanked 1 Time in 1 Post
mike_01 is an unknown quantity at this point
  Re: Excel to XML converter

Thanks for the pointers moredial, just wanted to ask if you or someone else here have the php script to parse the same ? I have found another way using the XML parsing through the MS excel 2003 but thats a real lengthly and manual process. Anyone care to share..

Thanks again.
__________________
"Falling down is not Defeat....Defeat is when you refuse to get up."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 30-10-07
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 503
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
  Re: Excel to XML converter

If you have a csv file with headings in the first line try this:

PHP Code:
<?php
header
("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('Content-type: text/xml');
$global_tag="product_list";
$outer_tag="product";
$tags=array();
$xml="<?xml version=\"1.0\" ?>\r\n";
$xml.="<".$global_tag.">";
$fp=fopen("filename.csv","r");
$data fgetcsv ($fp,8192);
$tags=$data;
while (
$data=fgetcsv ($fp,8192)){
$xml.="<".$outer_tag.">";
foreach (
$tags as $key=>$value){
$xml.="<".$value.">";
$xml.="<![CDATA[".$data[$key]."]]>";
$xml.="</".$value.">\r\n";
}
$xml.="</".$outer_tag.">\r\n";
}
$xml.="</".$global_tag.">";
echo 
$xml;
?>
If you don't have the headings in the first row change $tags=array() to $tags=array("col1","col2"); and leave out the first fgetcsv.

If your data is well formed for xml you don't need to have the cdata round the data. Change the line to $xml.=$data[$key]; and don't forget to change filename.csv to your own file name.

Regards Bob
__________________
They came for my 404 and I said nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 30-10-07
mike_01's Avatar
Life's changing...
 
Join Date: Nov 2005
Location: Planet_Zumbi
Posts: 295
Thanks: 4
Thanked 1 Time in 1 Post
mike_01 is an unknown quantity at this point
  Re: Excel to XML converter

Thanks for the script mate.. Will surely give it a try.

Thanks again,

Quote:
Originally Posted by Donk View Post
If you have a csv file with headings in the first line try this:

PHP Code:
<?php
header
("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('Content-type: text/xml');
$global_tag="product_list";
$outer_tag="product";
$tags=array();
$xml="<?xml version=\"1.0\" ?>\r\n";
$xml.="<".$global_tag.">";
$fp=fopen("filename.csv","r");
$data fgetcsv ($fp,8192);
$tags=$data;
while (
$data=fgetcsv ($fp,8192)){
$xml.="<".$outer_tag.">";
foreach (
$tags as $key=>$value){
$xml.="<".$value.">";
$xml.="<![CDATA[".$data[$key]."]]>";
$xml.="</".$value.">\r\n";
}
$xml.="</".$outer_tag.">\r\n";
}
$xml.="</".$global_tag.">";
echo 
$xml;
?>
If you don't have the headings in the first row change $tags=array() to $tags=array("col1","col2"); and leave out the first fgetcsv.

If your data is well formed for xml you don't need to have the cdata round the data. Change the line to $xml.=$data[$key]; and don't forget to change filename.csv to your own file name.

Regards Bob
__________________
"Falling down is not Defeat....Defeat is when you refuse to get up."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 30-10-07
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 503
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
  Re: Excel to XML converter

As an afterthought.

If you want stick to excel:
Insert a column in front of the data and also insert a new column after each of your current columns.

Delete the heading row
insert 2 rows at the top
cell A1 enter <?xml version="1.0" ?>
in cell A2 enter <product_list>
in A3 enter<product> and the start tag for the first column of you data. eg <product_id>
in C3 close the first tag and open the next eg </product_Id><product_name>
continue this in E3 G3 etc

After your last column you will need to close the preceding column tag and also the product tag eg </last_data></product>

Copy and paste these cell into every row
and finally after the final row close the </product_list> tag.

Save this as a text file and rename it with an xml extension.
__________________
They came for my 404 and I said nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
bit of a pickle, php xml parser morleymouse Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 5 20-01-06 02:52 PM
Excel Airways XML feed down drivetowin DGM Affiliates 2 15-08-05 10:31 AM
Excel Airways Doubles Commission rich2nd DGM Affiliates 0 06-10-04 03:35 PM
Anyone anygood with xml, php, mysql and Affiliate Window AnnonnyMouse The Affiliate Marketing Lounge 1 23-09-04 11:00 AM
datafeed help? xml - csv (excel) plesecontact The Affiliate Marketing Lounge 0 03-02-04 10:33 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7