How to create an XML file. Do you need to create a file in the metalanguage XML but you don't know how to do it? You have access to the Microsoft Office suite, would you like to export your data in XML format but cannot find the correct option to do so? Are you practicing with programming languages ​​and would like to create a script to export your data to an XML file? No problem: whatever your need to create XML files, Know that you have come to the right place at the right time!

How to create an XML file step by step

Basic Information

Before going into details about the procedure how to create an XML file, I think it is important to explain what it is, what it is used for and what its basic structure is.

XML is not a programming language (since it is not based on flows of actions linked to each other, nor on a basic algorithm), but a metalanguage for defining markup languages.

This last category of languages ​​does nothing more than mark a series of elements and specify their order of appearance: this means that the user must follow a certain "scheme" to create an XML file, in order to define and verify the meaning of the various elements .

XML files are widely used in databases, as they allow you to store a large amount of data, which can be extracted with a few instructions. The syntax is rigorous, but at the same time it is a "flexible" metalanguage, since allows to be instantly read and understood by a human user without having to go through specific software, and it can be used in countless ways.

The basic syntax involves inserting a initial label indicating the version of XML in use and the encoding used for data interpretation (), while later all the labels that make up the instructions are inserted.

XML data is represented by a start marker, un content and a final marker. Label / marker names can also be 'made up' according to user needs.

To give a concrete example, imagine having to «save»The last two articles published in .it. The starting marker will then be while the end will be (The symbol / closes a tag / bookmark, the same way it happens in HTML).

The content will obviously be the link to the articles and each of them will also have a home marker (in this case ), content (in this case, the name expressed as a parameter and the link to the article expressed as a separate label) and final (). Ours final code then it will be the following (as you can see, the labels are separated from each other through the button tongue keyboard).

In summary, as you may have already understood, it is an intuitive and relatively simple metalanguage to use in less demanding cases.

Programs to create XML files

Given the "power" and "flexibility" of XML files, many programs, such as the Microsoft Office suite, allow you to export your data to files with this extension. Below are all the details of the case.


Excel is the Microsoft Office suite program dedicated to the production and management of electronic spreadsheets.

To create an XML file with Excel, you must first enable the card development : to do this, press the item Archives present in the upper left and select the script Options located in the lower left.

After that click Ribbon Customization from the list on the left, check the box development on the right and press the button to accept.

Now press the icon development appears at the top and select the item export present on the right. You just have to choose the filename and press the button export.

In case there are problems or you are not satisfied with the result (Excel may add unnecessary information to the code), I advise you to consult the official Excel guidelines and guidelines related to mapping.

How to create an XML file from Word

Create an XML file using word It's very simple. Just open a simple empty text document, write the code and save it in the correct format.

Once you have finished write the code, just press the Files item in the upper left corner, select items one after another Save as y This PC, choose the filename (typing it in the appropriate text field), the binder where to save it (from the list below) select the extension . Xml from the appropriate list and press the button Save, present on the right.


Microsoft Access is the Office suite program capable of managing relational databases. For this reason, you may want to use this software to create an XML file.

To export data to XML using Access, all you have to do is press the element EXTERNAL DATA at the top and click on the icon XML files. At this point, you just need to select the binder where you want to save the output file and press the item to accept.

Perfect, you have now successfully exported the data to XML using Microsoft Access.


If you need convert a file PDF to XMLThere is a free program (for personal use, otherwise, it starts at $ 19.99) that allows you to do exactly that: Doxillion Document Converter, which is available for Windows and macOS. To facilitate the conversion process, your file should contain tables.

To get Doxillion Document Converter, connect to the official website of the program. and click the button Download present on the page.

After that, if you use Windowsopen the file doxpsetup.exe newly obtained, check the box I accept the license terms and press the button siguiente, to complete the configuration.

If, on the other hand, you are using MacOSopen the file obtained, click on the button I agree to extract the file Doxillion_i.dmg, also open the latter and drag Doxillion Document Converter in the folder applications of Mac.

At this point, launch Doxillion Document Converter, press the icon Add file (s) present in the upper left and select the PDF file to convert.

Now, choose the extension . Xml of menu Output format present at the bottom left, select the binder in which to save the output, first by clicking the button Surf and then Folder selection and finally press the icon convert (bottom right), to start the conversion process.

How to create XML files with programming languages

Is studying programming languages And would you like a help to create an XML file using a specific language of your interest? Don't worry - I'll explain how to do it right away.

Below you will find all the basic information on what you need to do, but if you have difficulties you will also find the link to the complete code (with a quote to the relative authors) to adapt it according to your needs.


If you use programming language Visual Basic 6 and you want to create an XML file and create it on disk, all you have to do is take advantage of these prompts.

The first thing to do is create all the objects related to your XML file.

The function to do this is called createElement ("Name"). After that, you need to create the various attributes and set their node value through function createAttribute ("Name") and the element nodeValue.

Finally, after setting everything up correctly, you can save the XML file to disk, through save function ("output-address filename.xml").

For all the details of the case and for the full procedure (complete with directions in English), I advise you to refer to the example code created by Andrew Park.


PHP is an interpreted scripting language often used to "talk" to databases. For this reason, it can be useful to use it to create XML files.

To do this, you must use the SimpleXML class, which allows you to easily manage this type of file. All you have to do, specifically, is use the function addChild ("start marker", "content"). After that, you will have to configure the header and use the function print.

For more information and the complete procedure, I invite you to consult the sample code created by Ivan Krechetov.

Create an XML file with C #

The object-oriented programming language VS #, developed by Microsoft within the initiative . NET, allows you to create an XML file through the base libraries Dotnet.

The parameters that you will use will be noNamespaces ( Boolean to create an XML file or a string without xmlns type definitions), elementsPrefix (prefix string for objects), namespaces (used to force the insertion of one or more xmlns attributes), slots (indicates if XMLWriter should indent the rows based on the labels), sangaree  (number of indentation spaces), newlineChars (format parameter) and useBOM (manages the control characters of the byte order mark).

For all the details of the case and for the full procedure, I recommend that you take a look at the example code created by Sabrina Cosolo.


As for the well-known programming language of high level Java, to create an XML file, you can go through a DOM parser.

To do this, you need DocumentBuilder and use the class element and the method appendChild to create the desired elements.

After that, just create the instances transformer y DOMSources and make one StreamResult for the output sequence.

Finally, you just have to use the method transform, to write the object in the desired stream.

For more information and the complete procedure, I invite you to consult the sample code of Nikos Maravitsas.

Create an XML file with ASP

To create XML files within the .NET Framework, you have to go through the XMLTextWriter class: I'll explain right away how to do it.

After importing the class mentioned above ( System.XML ), you will need to add the XML header, attributes and tags through the functions WriteRaw ("header"), WriteStartElement ("name"), WriteAttributeString ("attribute", "value") y WriteEndElement ().

For all the details of the case and for the full procedure, I advise you to consult the sample code created by Daniele Bochicchio.

How to create XML files of electronic invoices

The easiest way to generate a Electronic bill is to use an online service integrated with the Tax Agency system, such as Aruba's electronic invoicing service and InfoCert's legal invoice.

For all the details about the possible errors that may exist during the compilation phase, I advise you to consult the official website of the Electronic Invoice to the Public Administration.

How to create XML files online

With regards to generation of XML files online, instead my advice is to use the tool provided by Tutorialspoint, which also allows you to become familiar with the metalanguage.

To continue, therefore, connect to the official Tutorialspoint website and start edit the sample code according to your needs.

Once you have finished creating the XML, press the button Download present in the upper right corner to download it to your PC. I remind you that on the right side of the screen you can see the » XML tree «, While on the left you can edit the bar code.