Use Scriptella to convert XML to CSV, how to get attribute values?

I found an example of converting XML to CSV. In the example used, this structure is




Empire Burlesque
Bob Dylan< br /> USA
Columbia
10.90
1985

In this file structure, Scriptella code:





How to convert an XML file with the following structure



.............

How to get the attribute value in XML?

First, the driver needs to be described correctly for all connections. Scriptella cannot be used unless the xpath driver is used Parse XML. More information: http://scriptella.org/reference/drivers.html

Now the magic bit:
– You can use the Java library as an alternative possibility, But since these two drivers are available out of the box, I suggest to use them
-you want to import xml-> need xpath driver
-you want to export csv-> need csv driver
– The text driver can also be used to output csv data, but you must manually handle the quotation and delimiter

If your xml data is in the file data.xml, and you want to use it as a file in data.csv For csv data export, I suggest using the following scriptella etl script:

< br />


quote=
separator=;



/CATALOG/CD


Please respect the case used in the XML source. You must use $TITLE instead of $title or $Title, because exists in the XML source.</p> <p>This type of ETL task is not required rownum test.</p> </div></p><p>I found an example of converting XML to CSV. In the example used, this structure is <p></p> <p></p> p> <pre><!-- Demo input for ETL --><br /><CATALOG><br /> <CD><br /> <TITLE>Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985

In this file structure, the Scriptella code:

 


/CATALOG/CD


How to convert an XML file with the following structure



.............
< br />

How to get the attribute value in XML?

First, you need to describe the driver correctly for all connections. Unless you use the xpath driver, you cannot use Scriptella to parse XML. More information: http://scriptella .org/reference/drivers.html

Now the magic bit:
-You can use the Java library as an alternative possibility, but since these two drivers are available out of the box Yes, I suggest to use them
– you want to import xml –> need xpath driver
– you want to export csv –> need csv driver
– text driver can also be used to output csv data, but you The quotation and separator must be processed manually

If your xml data is in the file data.xml and you want to export it as csv data in the file data.csv, I recommend using the following scriptella etl script:





quote=< br /> separator=;



/CATALOG/CD


Please respect the case used in the XML source. You must Use $TITLE instead of $title or $Title, because Exists in the XML source.

This type of ETL task does not require rownum testing.

Leave a Comment

Your email address will not be published.