I am wondering if there is a program that will allow me to open up the XML feed file to edit it. More specifically something like excel, where each field is separate. This would be used to remove products that I do not want imported.
I am aware of the filter options - however in this case it really would be just a matter of manually editing.
Essentially a reverse tool that would bring the feed file back to a delimited file.
Thanks.
Hi Steven,
XML is a very difficult format to be edited manually i'm afraid, especially when files are very large. An alternative would be to convert the XML to CSV, which can then of course be edited far more easily. There is code to do this on the Magic Parser website in the following thread:
http://www.magicparser.com/node/464
(Magic Parser is included in Price Tapestry so you already have the script)
If you want to implement this it would make sense to include the correct Format String for the XML feed in the script. You can get this from the Feed Registration (Step 1) page for the feed you want to edit (assuming that it auto-detects correctly - in other words you can just click "Next" and the sample data appears correctly on Step 2).
In addition, you will need a folder that is writable by PHP in which to create the output file. I would create it in the main Price Tapestry installation folder - for example "temp", and make it writable by all users. The easiest way to do this is normally with your FTP program. Create the folder, and then right-click on the folder in the remote window and look for "Permissions..." or perhaps "Properties..." and then Permissions; and give write access to all users - Owner / Group / World. With that in place, try the following script, running in the main Price Tapestry folder - replacing the values of $filename and $formatString on the first 2 lines as required:
xml2csv.php
<?php
$filename = "MerchantName.xml";
$formatString = "xml|PRODUCTS/PRODUCT/";
require("includes/MagicParser.php");
function myRecordHandler($record)
{
global $csv;
// strip commas, new-line and carriage return characters from all fields
foreach($record as $key => $value)
{
$record[$key] = str_replace(","," ",$value);
$record[$key] = str_replace("\n"," ",$value);
$record[$key] = str_replace("\r"," ",$value);
}
fwrite($csv,implode(",",$record)."\n");
}
$csv = fopen("temp/".$filename.".csv","w");
if (!$csv) { print "Could not create output file - check permissions!";exit(); }
MagicParser_parse("feeds/".$filename,"myRecordHandler",$formatString);
fclose($csv);
?>
Cheers,
David.