Free to use, no account

XML til CSV-konverterer

Gjør en enkel XML-liste over poster om til en CSV-tabell, eller lag XML-poster fra teksten i en CSV-fil. Velg retning, lim inn dataene, og kopier eller last ned resultatet. Ingenting lastes opp.

Støtter en enkel liste med like navngitte postelementer eller én flat post. Elementbarn må ha skalarverdier; nestede og gjentatte felt flates ikke ut.

Dette er en enkel tabellkonvertering, ikke en tapsfri XML-konvertering. Navnerom, nestede strukturer, blandet innhold, kommentarer og XML-formatering beholdes ikke. Teksten tolkes ikke etter datatype. CSV-verdier som kan ligne regnearkformler, får en apostrof foran av sikkerhetshensyn.

Hvordan konverterer jeg XML til CSV?

Velg XML til CSV og lim inn XML med en enkel liste over poster. Gjentatte, direkte postelementer blir til rader. Elementnavn blir kolonner; attributter bruker @navn. Velg CSV til XML for å lage enkle XML-poster fra overskrifter og rader.

Veiledning

Slik bruker du xml-to-csv-converter

The XML to CSV Converter turns a simple list of same-name XML records into a CSV table, or turns CSV text back into simple XML records. You choose the direction, paste your data, then copy or download the result. It is built for flat, table-shaped data. It does not flatten nested XML, and nothing is uploaded.

Slik gjør du

  1. Pick the direction, XML to CSV or CSV to XML. The matching input box appears, filled with a short sample you can overwrite.
  2. Paste your data. For XML, use one wrapper element holding repeated record elements. For CSV, use the first row for names. A header such as @id becomes an attribute, and #text becomes the record text.
  3. For CSV to XML, you can change the root and record names. Press Convert, check the output, then use Copy output or Download output.

Eksempler

The sample product list

Du skriver inn
retning
XML to CSV
XML
<products><product id="101"><name>Notebook</name><price>4.50</price></product><product id="102"><name>Pen</name><price>1.25</price></product></products>
Du får
CSV
name,note,city "Ana, Maria",'=SUM(A1:A2), Luis,,Cadiz

Each repeated product element becomes a row. The id attribute becomes a column named @id, and the child elements name and price become columns of their own.

Kjørt med verktøyets egen kode.

Commas and a formula-like value

Du skriver inn
retning
XML to CSV
XML
<people><person><name>Ana, Maria</name><note>=SUM(A1:A2)</note></person><person><name>Luis</name><city>Cadiz</city></person></people>
Du får
CSV
name,note,city "Ana, Maria",'=SUM(A1:A2), Luis,,Cadiz

A comma inside a value gets quotes around it. A value starting with an equals sign gets an apostrophe in front, so a spreadsheet will not run it. A missing field leaves an empty cell.

Kjørt med verktøyets egen kode.

CSV back to XML with your own names

Du skriver inn
retning
CSV to XML
CSV
@id,name,price 101,Notebook,4.50 102,Pen,1.25
rotelement
products
postelement
product
Du får
XML
<?xml version="1.0" encoding="UTF-8"?> <products> <product id="101"><name>Notebook</name><price>4.50</price></product> <product id="102"><name>Pen</name><price>1.25</price></product> </products>

The @id header turns into an attribute, and the other headers turn into child elements. Special characters such as an ampersand or angle bracket in the data are written as XML entities.

Kjørt med verktøyets egen kode.

A record with a repeated field

Du skriver inn
retning
XML to CSV
XML
<shop><item><name>A</name><tag>x</tag><tag>y</tag></item><item><name>B</name></item></shop>
Du får
melding
A record repeats a field name. Use a different table layout because repeated values cannot fit one cell safely.

Two tag elements inside one item cannot share a single cell, so the tool stops with a message instead of dropping one of them or joining them in secret.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Open a flat XML export from a shop, feed or old system in a spreadsheet.
  • Build simple XML records from a small CSV sheet for a form, a test or an import file.
  • Check whether a data file is flat enough to convert without losing anything.

Begrensninger

  • Only simple data fits: a list of same-name record elements, or one flat record. Nested elements, repeated fields inside a record and mixed text are rejected, not flattened.
  • Input is capped at 200,000 characters, 5,000 rows, 64 columns and 20,000 cells. DTD and entity declarations are blocked, and nothing external is fetched.
  • The conversion is not lossless. Namespaces, comments, formatting and data types are not kept, and every CSV cell is plain text.
  • CSV headers must be unique and made of simple names. Rows must have the same number of cells as the header row, or the tool refuses the file.

Tips

  • Wrap a single item in its own parent if the tool says the structure is ambiguous, so the records are clearly repeated elements.
  • Check the first few rows in a spreadsheet after import, because numbers with leading zeros may be changed by the spreadsheet.
  • Open the CSV as text before importing it, so you can spot an apostrophe that was added to protect a formula-like cell.

Vanlige spørsmål

How do XML attributes appear in the CSV?

An attribute such as id="101" becomes a column named @id. When you convert in the other direction, any CSV header that begins with an at sign is written back as an attribute on the record element.

Why was my XML rejected as ambiguous?

The tool cannot tell if a wrapper holding several same-name simple elements is a list of records or one record with repeated fields. Wrap each record in its own element, then repeat that element.

Can it convert nested XML into a flat table?

No. Nested child structures, repeated fields and mixed text are refused rather than flattened or silently lost. For nested data, use a tool that converts to JSON or write a custom mapping.

Why does an apostrophe appear before some CSV values?

Values that begin with an equals, plus or at sign, or a minus that is not a plain number, get a leading apostrophe on export. This lowers the risk of a spreadsheet running them as a formula.

What does the #text header do?

In CSV to XML, a column named #text writes its value as the text inside the record element itself, not in a child element. In XML to CSV, text inside a record that has no child elements appears under that name.

Is my data uploaded to a server?

No. Parsing and conversion run in your browser, and no external resources are fetched. Because the result lives only on the page, copy or download it before you close the tab.

Ofte stilte spørsmål

Hvordan konverterer jeg XML til CSV?

Velg XML til CSV og lim inn XML med en enkel liste over poster. Gjentatte, direkte postelementer blir til rader. Elementnavn blir kolonner; attributter bruker @navn. Velg CSV til XML for å lage enkle XML-poster fra overskrifter og rader.

Lastes XML- eller CSV-filen min opp?

Nei. Tolking og konvertering kjøres i denne nettleseren. Inndata er begrenset til 200 000 tegn, 5 000 rader, 64 kolonner og 20 000 celler. DTD- og entitetserklæringer blokkeres, og eksterne ressurser hentes ikke.

Hvordan vises XML-attributter i CSV?

Et attributt som id="101" blir en kolonne med navnet @id. Ved konvertering tilbake blir en CSV-overskrift som starter med @, et XML-attributt.

Kan verktøyet gjøre nestet XML om til en flat tabell?

Nei. Nestede understrukturer, gjentatte felt i en post og blandet tekst avvises i stedet for å flates ut eller gå tapt uten varsel. Bruk en egen XML-til-JSON-flyt for nestede data.

Bevarer CSV XML-typer og formatering?

Nei. CSV lagrer celletekst, ikke XML-typer, navnerom eller formatering. Celleverdier som ligner formler, får en apostrof foran ved eksport for å redusere risikoen for at regnearket kjører dem.