Link to home
Start Free TrialLog in
Avatar of greenrc
greenrc

asked on

Convert XML to CSV

I need to convert an XML file into a CSV file.

If i have an XML file formatted as follows:

<root>
<table1 id="100" description="this is a test" anotherfield="test test" />
<table1 id="101" description="this is a test" anotherfield="test test" />
<table1 id="102" description="this is a test" anotherfield="test test" />
<table1 id="103" description="this is a test" anotherfield="test test" />
</root>

The transformation needs to handle more fields
than shown in the example XML file above. Is there a way to loop through attributes?

Can you please provide me with a sample XSL file to  tranform.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of robbert
robbert

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
Avatar of Zlatin Zlatev
>Is there a way to loop through attributes?

<xsl:template match="@*">
  <!--
    some stuff
  -->
</xsl:template>

>I need to convert an XML file into a CSV file

What output do you expect from the XML you have provided? I am far from understanding your idea.

Kind Regards,
Zlatin Zlatev, MCSD
Avatar of greenrc
greenrc

ASKER

works like a charm

thanks robbert
How can I make this handle nested nodes?

i.e. From:
<Area code="Lon">
  <Destination name="London" country="England" />
</Area>

To:
Lon, London, England

Thanks

Nigel

@Nigel_Ellis, better post a new question. It seems, that not everyone knows about your question here, to answer it.