Why XML Attributes Matter in Tabular Data (and How to Keep Them as Columns)
You open a new CSV file. The names look right. The prices look right. Then you look for the ID column. It is not there.
That loss is common, and it is easy to miss. The file has no error. The loss hides in what is not there.
In many XML files, that key fact was in an attribute. An attribute is a small label that sits inside a tag. If a tool drops attributes, it drops those labels. The rest of the file can still look fine.
This guide explains what an attribute is, why teams put key facts in attributes, and what you lose when they are dropped. It also shows how to keep them. On XmlToCsv, attributes are kept as columns, and each column name shows where the value came from.
You can try it on your own file with the converter first, then use the checks below to test the result.
Element and Attribute: Two Places to Store a Fact
XML is a text format for data. A format is a set of rules for how data is written. XML uses tags to mark each piece of data.
An element is a part marked by a start tag and an end tag. The text between the tags is its value.
An attribute is a name and a value inside the start tag. It adds a fact about that element.
<product id="BK-1001" currency="USD">
<price>19.99</price>
</product>
Here, product and price are elements. The value of price is 19.99. The word id is an attribute of product, with value BK-1001. The word currency is also an attribute, with value USD.
One short block holds three facts. One is in element text. Two are in attributes.
If a tool reads only element text, it finds the price. It misses the ID and the currency. The price alone can mislead you. A price of 19.99 in US dollars is not the same as 19.99 in another currency.
Think of an element as a box. The text inside is one fact. Attributes are labels on the outside. A table needs both. That is the idea of xml attributes to columns: each attribute becomes its own column.
Why Teams Put Key Facts in Attributes
Teams use attributes for facts that describe the whole element. These facts are often short codes. They are often the facts you need most in a sheet.
IDs and Codes
An ID is a short code that names one record. No two records should share the same ID in the same set.
A product may have id="BK-1001". An order may have id="ORD-8841". A part may have a SKU code. A SKU is a code a shop uses to track one kind of item.
In a sheet, the ID is often the most used column. You use it to join tables. A join is a match between rows in two tables that share a value. Lose the ID, and you lose the link to other data. Names can repeat. IDs are meant to stay unique.
Money and Currency
Money needs a unit. The currency attribute gives that unit. Currency is the kind of money, such as US dollars or euros.
A price element may hold just a number. The currency may sit on the price tag or on the parent tag. If you keep only the number, you can add prices that should not be added, and sums will be wrong.
Language
Language is the tongue a text is written in, such as English or French. The text of each title is in the element. The language code is often in an attribute, such as lang="en" or lang="fr".
If you drop that attribute, titles in two languages may land in the same column. You will not know which is which.
Units of Measure
A unit is how a value is measured. Weight may be in grams or pounds. The number is often the element text. The unit is often an attribute. Keep the number and drop the unit, and a weight of 2 could be light or heavy. It depends on the unit.
Status Flags
A status flag is a short code that says what state a record is in. State means if a thing is live, draft, paid, or closed.
Status is a prime filter field. A filter is a rule that keeps only rows that match. You may want only live products or only paid orders. If the status was an attribute and it was dropped, you cannot filter on it.
In short, dropped attributes are the quietest form of data loss because nothing looks broken. The file opens. The loss is silent.
Common Attribute Jobs at a Glance
| Job | Example attribute | Example value | Why you need the column |
|---|---|---|---|
| Identifier | id | BK-1001 | Join tables, find one row, spot repeats |
| Money currency | currency | USD | Know what the price means |
| Language | lang | en | Pick the right text for each reader |
| Unit | unit | kg | Know what the number measures |
| Status | status | active | Filter to live, paid, or open rows |
| Type code | type | sale | Split rows by kind |
Use this table as a check list. If fields like these live in attributes, your tool must keep them.
What Happens When a Converter Drops Attributes
Some tools read only element text. They drop attributes without a note. That changes what the table means.
First, the ID column is simply gone. You cannot join the table to stock, sales, or shipping data. You may try to join on name, but names repeat and names change.
Second, prices lose their currency. A sheet of prices in mixed currency looks like one clean list of numbers. Sums built on that list will be wrong. No cell will show an error. Only the meaning is wrong.
Third, filters break. You cannot keep only active rows if the status column is gone. You cannot keep only English text if the language column is gone.
Fourth, checks get hard. You count rows and the count is right, so you trust the file. The missing columns show up later, when a join fails or a total is wrong.
Test any tool with a small file first. Use a file where you know the attributes, and check that each one shows up as a column.
For the full flow, see the step-by-step conversion guide. It walks through upload, row choice, preview, and export in order.
How the name@attribute Column Naming Works
A good name must tell you which element the attribute belongs to, and which attribute it is.
XmlToCsv uses a simple rule. The column name is the element name, then @, then the attribute name. So id on product becomes product@id. And currency on product becomes product@currency.
The @ sign marks an attribute. When you see @ in a column name, you know the value came from an attribute. A plain name with no @ came from element text.
This rule solves a real clash. The same attribute name can appear on more than one element. Both product and price could have a type attribute. With the full rule, one is product@type and the other is price@type.
A preview is a quick look at the first rows before you export. On XmlToCsv, the preview shows the first rows plus the total row count. You can spot the @ columns at once.
A Small Example, From XML to CSV
Each product below has an ID and a currency in attributes. Each has a name and a price as elements.
<products>
<product id="BK-1001" currency="USD">
<name>Blue Mug</name>
<price>19.99</price>
</product>
<product id="BK-1002" currency="EUR">
<name>Green Plate</name>
<price>24.50</price>
</product>
</products>
The repeating record tag here is product. That tag is called the row element. The row element is the tag that repeats for each row. XmlToCsv finds it on its own. You can also pick another tag, or type a path to the tag you want.
With attributes kept, the result is:
| product@id | product@currency | name | price |
|---|---|---|---|
| BK-1001 | USD | Blue Mug | 19.99 |
| BK-1002 | EUR | Green Plate | 24.50 |
The same result as CSV text is below. CSV is a plain text format where commas split the columns. Each line is one row.
product@id,product@currency,name,price
BK-1001,USD,Blue Mug,19.99
BK-1002,EUR,Green Plate,24.50
With attributes dropped, you would have only name and price — the two columns you need least on their own.
Child Elements That Repeat
Some records hold a list inside one row. On XmlToCsv, repeated child values can be joined with ; in one cell, or expanded to one row per value. Join for one row per record. Expand to count each value on its own row.
Practical Checks Before You Trust the Output
Keeping attributes is step one. Checking them is step two.
1. Compare the Column List Against the Source
List the attributes for one record in the source. Then open the preview and match each attribute to a column. If one is missing, stop and fix the setup.
Pick a record in the middle of the file, not just the first one. Some records have extra attributes that the first one lacks.
2. Watch for the Same Name on Different Elements
Names like type, id, and code can appear on many elements. Check that column names use the full element@attribute form. Also check the values. If product@id and part@id both exist, one may name the product and the other a part in it. Keep both if you need both.
3. Decide Which Columns to Keep or Drop
Not every attribute must stay. Some are for the source system only. Keep the ones you will join, filter, sort, or report on. Drop the rest, but make that choice on purpose. A column lost by default is not a choice.
4. Rename Columns in a Saved Template
Raw names like product@currency are clear, but your team may want short names in reports, such as Currency.
Paid plans can save field mapping templates. A field mapping is a set of rules that says which source field goes to which column, and what that column is called. A template saves those rules for reuse. That helps with feeds you get each week or month. In fact, feeds often hide key fields in attributes, so a saved template keeps the same fix in place each time.
Plans differ in file size and use. Free covers files up to 2 MB, Starter up to 25 MB, and Pro up to 100 MB. Free gives 10 conversions per month, with export up to 5,000 rows. Starter is $9 per month. Pro is $19 per month.
5. Check Values and Row Count by Hand
Pick three rows. Find each record in the source and check the ID, currency, and status by eye. This catches swapped columns and wrong row choices. The preview shows the total row count. That count should match the number of row elements in the source.
6. Export in the Right Format
XmlToCsv exports to CSV and to XLSX. XLSX is the file format for Excel sheets. Use CSV for simple imports. Use XLSX for a ready sheet.
When the XML Is Broken
Not all XML is valid. Valid means the file follows the XML rules. A file can have a missing end tag, a bad character, or the same attribute twice on one element, which XML does not allow.
You need a clear error, not a silent fail. On XmlToCsv, broken XML gives a clear error with line and column numbers, so you can fix the tag or value and run the job again.
Large files add one more need. XmlToCsv processes large files with streaming. Streaming means the tool reads the file in small parts, one part at a time.
A Short Worked Plan You Can Reuse
First, find the repeating tag and note its attributes. Second, run a small test and look at the preview. Third, match the column list to your notes. Fourth, fix the mapping: drop columns you do not need, and rename the rest. Fifth, check three rows by hand and check the total row count. Sixth, export to CSV or XLSX, and save the mapping as a template if you will do this job again on a paid plan.
This plan works for product feeds, order exports, and stock lists. The source changes. The checks stay the same.
Frequently Asked Questions
Can an attribute repeat on the same element?
No. One element can hold only one value for each attribute name. That is a real XML rule. A tag cannot have id twice. If you need more than one value, the data should use child elements that repeat.
Can two elements use the same attribute name?
Yes. Each element can have its own id or type. The full column name keeps them apart, such as product@id and part@id.
What if an attribute is missing on some records?
Then that cell will be blank for those rows.
Do attribute values need quotes?
Yes. In XML, attribute values are written in quotes. A missing quote is one cause of a broken file error.
Should I keep every attribute column?
No. Keep what you will use. The key point is that the choice is yours. The tool should show you the columns first.
Key Points to Remember
Attributes are not extra detail. They often hold the ID, the currency, the language, the unit, and the status. Those are the columns you join, filter, and trust. Test for the @ columns, compare them to the source, and check a few rows by hand.
References
- https://www.w3.org/TR/xml/ — The W3C XML specification. Its section on attributes sets the rules for attribute names and values, and why one name can appear only once on an element.
- https://developer.mozilla.org/en-US/docs/Web/XML/Introduction — MDN's introduction to XML. It gives a plain first look at elements, tags, and attributes for new readers.