I see a post Convert XML to CSV (with node path as header) using XSLT, the poster have this XML data:
<tXML>
<Header>
<Source>XPTO</Source>
<User_ID>127</User_ID>
<Message_Type>Ship</Message_Type>
<Company_ID>105</Company_ID>
<Msg_Locale>English (United States)</Msg_Locale>
<Version>2017</Version>
</Header>
<Message>
<Ship>
<ShipSummary>
<ComName>XPTO 123</ComName>
<FacName>6</FacName>
</ShipSummary>
</Ship>
</Message>
</tXML>
He want to convert to CSV like this:
tXML/Header/Source,tXML/Header/User_ID,tXML/Header/Message_Type,tXML/Header/Company_ID,tXML/Header/Msg_Locale,tXML/Header/Version,tXML/Message/Ship/ShipSummary/ComName,tXML/Message/Ship/ShipSummary/FacName XPTO,127,Ship,105,English (United States),2017,XPTO 123,6
I don’t like using XSLT, I like my tool Data File Converter, so I test, it can do this, in a minute.
1. Open XML file, set XML options.
2. set CSV options.
3. “Next” and “Next”, convert, get output CSV file.
XML → CSV reference
Type mapping
| Value kind | in XML | in CSV |
|---|---|---|
| Int | <int>1234</int> | 1234 |
| Bigint | <bigint>9007199254740993</bigint> | 9007199254740993 |
| Decimal | <decimal>1234.56</decimal> | 1234.56 |
| Float | <float>1.234e10</float> | 1.234e+10 |
| Text | <char>text</char> | quoted only when it contains a comma or a quote |
| Long text | <text>multi-line text</text> (entities for & <) | must be quoted; line breaks inside force multi-line records |
| Date | <date>2026-09-18</date> (xs:date with an XSD) | 2026-09-18 |
| Datetime | <datetime>2026-09-18T14:30:00Z</datetime> (xs:dateTime) | 2026-09-18 14:30:00 |
| Binary | <blob>base64...</blob> (xs:base64Binary) | not representable - base64 or hex string |
| Boolean | <bool>true</bool> | TRUE / FALSE, or 1 / 0 depending on the writer |
| JSON | escaped inside an element, or its own sub-tree | the whole JSON value quoted, with internal quotes doubled |
Dialect differences
Both XML and CSV are file formats, so what differs below is how each one chooses to represent a value.
| Property | in XML | in CSV |
|---|---|---|
| identifiers | Attribute values in quotes; entities (& < >) for ... | Double quotes; a literal quote is doubled ("" ) |
| dates | Text (xs:date / xs:dateTime when an XSD is in play) | Conventional text: 2026-09-18 or 2026-09-18 14:30:00 |
| binary | base64Binary / hexBinary inside text | Not supported |
| separator | Tags, not delimiters | Comma "," |
| encoding | Declared in the XML declaration | No declaration - UTF-8 works only with a BOM |
| typing | None in the markup itself | None - every field is text |
| shape | Arbitrary tree | Flat table, optional header row |
| ceiling | Whole document is usually parsed into memory | No formal limit; row count bounded by memory |
Convert your data online, free
Free in-browser converters for CSV, Excel, JSON, XML and SQL: Withdata Online Data Conversion. Large files, batch conversion or scheduling? See the offline desktop apps, or browse all data conversion tools.