|
Supports complicated XML structure by using aliases
XML2CSV allows you to convert a very sophisticated XML document to a CSV file. To extract data from complicated XML structure you should just specify aliases in the field's file. Each alias contains the full name of the element or the attribute to be extracted. The full name of the element contains names of all ancestors beginning with the name of the root element.
Suppose there is a XML file:
<orders>
<order>
<seller><fname>Jose</fname></seller>
<buyer><fname>Carlos</fname></buyer>
<assistant fname="Bill" id="2"/>
<assistant fname="Scott" id="3"/>
</order>
.......
and resulting CSV string should be:
Jose, Carlos, Bill, Scott
You should specify aliases in the fields file.
seller, buyer, assistant_1, assistant_2
seller = orders>order>seller>fname
buyer = orders>order>buyer>fname
assistant_1 = orders>order>assistant|fname
assistant_2 = orders>order>assistant|fname
|
 (Click on image to enlarge)
|
|
Common attributes and elements can be inserted into each row
Suppose there are some elements or attributes that you want
to insert into each row of the csv file.
<order type="FOB">
<title>ZUT56</title>
<item name="HETZ" price="34.00"/>
<item name="MJFH" price="20.00"/>
<item name="HFZG" price="10.70"/>
<item name="IKRG" price="25.90"/>
</order>
and a csv file you want to be:
type,title,name,price
"FOB","ZUT56","HETZ","34.00"
"FOB","ZUT56","MJFH","20.00"
"FOB","ZUT56","HFZG","10.70"
"FOB","ZUT56","IKRG","25.90"
The "type" attribute is a common attribute for each item element.
You can specify the "type" alias as a common attribute and
the "title" alias as a common element by using "==" instead of "=".
type,title,name,price
type == order|type # common attribute
title == order>title # common element
name = order>item|type
price = order>item|type
|
|