I see a post Convert xml (mixed nodes and attributes) to csv file using c#, the poster has an XML which has mix of nodes and nodes with attributes:
<?xml version="1.0" encoding="utf-8"?>
<Root>
<StudentRequestList count="3">
<StudentRequest>
<StudentFirstName>Test1</StudentFirstName>
<StudentLastName>TestLastName</StudentLastName>
<StudentGrade>3</StudentGrade>
<StudentHomeroomTeacher>WhiteTest1</StudentHomeroomTeacher>
<VariableData>
<Variable name="Email">test@email.com</Variable>
<Variable name="Hobby1">TestHobby1</Variable>
<Variable name="Hobby2">TestHobby2</Variable>
<Variable name="Hobby3">TestHobby3</Variable>
<Variable name="satscore">satscoreTest1</Variable>
<Variable name="kprepscore">krepscore1</Variable>
</VariableData>
</StudentRequest>
<StudentRequest>
<StudentFirstName>Test2</StudentFirstName>
<StudentLastName>TestLastName2</StudentLastName>
<StudentGrade>3</StudentGrade>
<StudentHomeroomTeacher>WhiteTest1</StudentHomeroomTeacher>
<VariableData>
<Variable name="Email">test2@email.com</Variable>
<Variable name="Hobby5">TestHobby5</Variable>
<Variable name="Hobby6">TestHobby6</Variable>
<Variable name="Hobby3">TestHobby3</Variable>
<Variable name="satscore">satscoreTest2</Variable>
<Variable name="kprepscore">krepscore2</Variable>
</VariableData>
</StudentRequest>
<StudentRequest>
<StudentFirstName>Test1</StudentFirstName>
<StudentLastName>TestLastName</StudentLastName>
<StudentGrade>3</StudentGrade>
<StudentHomeroomTeacher>WhiteTest1</StudentHomeroomTeacher>
<VariableData>
<Variable name="Email">test@email.com</Variable>
<Variable name="Hobby4">TestHobby4</Variable>
<Variable name="Hobby2">TestHobby2</Variable>
<Variable name="Hobby3">TestHobby3</Variable>
<Variable name="satscore">satscoreTest3</Variable>
<Variable name="kprepscore">krepscore3</Variable>
</VariableData>
</StudentRequest>
</StudentRequestList>
</Root>
CSV is supposed to look like:
StudentFirstName,StudentLastName,StudentGrade,StudentHomeroomTeacher,Email, Hobby1, Hobby2,Hobby3, Hobby4, Hobby5, Hobby6, satscore, kprepscore Test1,TestLastName,3,WhiteTest1,test@email.com,TestHobby1,TestHobby2,TestHobby3,,,,satscoreTest1,krepscore1 Test2,TestLastName2,3,WhiteTest1,test2@email.com,,,Hobby3,,Hobby5,Hobby6,satscoreTest2,krepscore2 Test1,TestLastName,3,WhiteTest1,test@email.com,,Hobby2,Hobby3,Hobby4,,,satscoreTest3,krepscore3
I think Data File Converter can do this, need to coding, so I tried, yes, it can, in a minute.
1. Open XML file in DataFileConverter, set XML options.
2. Set XML custom columns.
3. Set CSV options.
4. “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.