Link to home
Start Free TrialLog in
Avatar of Alan Keane
Alan Keane

asked on

PHP converting XML to CSV, capturing atributes on unique field tags

Hi Guys,

I need to convert an XML to CSV, I have a example of both attached and a script I was trying to adapt to the job. However it continues to cause fail to upload.

I wish to write multiple XML files into the same CSV file thereby building a log of all incoming jobs.
Here is an example of the XML:
"<?xml version='1.0' encoding='UTF-8'?>
<ValueDescription Type="metadatafields">
 <MF_1 LocalizedTagName="Customer Name" ValueIsRequired="Yes" Format="" Tooltip="Customer Name" Editor="inline" DisplayField="Yes" Type="string" ReadOnly="No" FormatEditor="inline" RememberLastValue="Yes" Subtype="inline">Novah</MF_1>
 <MF_2 LocalizedTagName="Contact Name" ValueIsRequired="Yes" Format="" Tooltip="Contact Name" Editor="inline" DisplayField="Yes" Type="string" ReadOnly="No" FormatEditor="inline" RememberLastValue="Yes" Subtype="inline">Damien</MF_2>

I need to capture each of the "MF_*" fields in this file in particular the LocalisedTagName attribute in each field, this will be set to the header of the CSV file while "MF_* " data is capture as a value for said LocalisedTagName.

IF someone can help point me in the right direction.

Thanks for your help
25-08-16.csv
demoWFconvert.php
Job455.xml
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Do you have any control over the format of the XML document?  It seems awkward to me and might benefit from more straightforward formatting.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tested and working code examples provided.  Author abandoned.