Convert a file to XML format
You have the perfect file with all of your product or statistical data, and now you need this data in XML format. Converting a file to XML is actually much easier now than it used to be when XML first became popular. There are many tools available to convert files from one format to another. Of course, these tools are absolutely useless unless your data is prepared to be converted. Data should be structured and organized so that it can be converted into XML properly.
Step 1
What format is your original file? Your file type will be the determining factor in how you approach the conversion. If your file is one of the following types, you are in luck. Your application will convert it for you:
Microsoft Excel: Do a Save As XML file.
Microsoft Access: File | Export | Save as XML File
Note: It is important to note that Microsoft files are exported in a certain format. These documents may or may not be what you expect. They contain elements that pertain to the formatting of your Excel document. This would not be ideal if you are using the data in an application that is particular about the format of the incoming data.
If, on the other hand, your document is not in any of those formats, you will have to either search for a converter tool or convert it by hand (unless you have too much to convert by hand).
Software such as XML Spy can convert your SQL-based code into XML documents as well. When you have a large data set, a converter is highly recommended. According to its references, you can work with:
- ADO
- Oracle
- mySQL
- SQL Server
- ODBC
- Sybase
- MS Access
- Excel
- Tab Delimited, CSV
There are other converter tools such as Rustemsoft's XML Converter or XML Buddy (Eclipse plugin) from Bocaloca software. These applications can export your data and also provide you with an XML Schema or DTD (document type definition) file if desired. These applications are very handy and make the process of converting your file or database to XML much more user-friendly.
Step 2
If you are at this step, you must convert it by hand. In the real world, you may not actually even have it originally in Microsoft Excel. Let's take a basic text document and convert it to XML. But first things first: how about a quick review of the basic rules of XML?
XML - The Extensible Markup Language is a text-based, cross-platform language that enables you to store data (like addresses in an address book) in a structured manner. The XML document is expected to have correct syntax. Therefore, when making XML documents, they should be well-formed. A well-formed document has the following:
- Closed tags (
or ) - An element's attribute must be enclosed in double quotes (
) - XML is case sensitive. In other words, the beginning and ending tags should use the same case.
Here is a basic list of 17th century Dutch painters.
Rembrandt Van Rijn, 1606-1669, Night Watch
Hendrick Avercamp, 1585-1634, Winter
Jan de Bisschop, 1628-1671, The Oostpoort
As you can see, the data is separated by commas, also known as a comma-delimited file. Each line is a separate chunk of data. Each chunk has the painter's name, birth to death year, and finally one of their paintings. Therefore, we need to build an XML file with the following structure:
- Painter's Name
- Painter's Year of Birth
- Painter's Year of Death
- Painter's Painting
Step 3
With this format in mind, we can create an XML file. Our root element will be called painters since we have a list of painters.
Rembrandt Van Rijn
1606
1669
Night Watch
Hendrick Avercamp
1585
1634
Winter
Jan de Bisschop
1628
1671
The Oostpoort
Each painter becomes a sub-element of painters called painter. Each of our painters has two dates associated with them as well as a painting. Therefore, we are going to make the name, dates, and painting child elements of the element painter. They are going to be called name, yearofBirth, painting, and yearofDeath. With this file, we have our converted data ready to be used as we see fit.
Convert a file to XML format
Convert a file to XML format : Multi-thousand tips to make your life easier.
You have the perfect file with all of your product or statistical data, and now you need this data in XML format. Converting a file to XML is actually much easier now than it used to be when XML first became popular. There are many tools available to convert files from one format to another. Of course, these tools are absolutely useless unless your data is prepared to be converted. Data should be structured and organized so that it can be converted into XML properly.
Step 1
What format is your original file? Your file type will be the determining factor in how you approach the conversion. If your file is one of the following types, you are in luck. Your application will convert it for you:
Microsoft Excel: Do a Save As XML file.
Microsoft Access: File | Export | Save as XML File
Note: It is important to note that Microsoft files are exported in a certain format. These documents may or may not be what you expect. They contain elements that pertain to the formatting of your Excel document. This would not be ideal if you are using the data in an application that is particular about the format of the incoming data.
If, on the other hand, your document is not in any of those formats, you will have to either search for a converter tool or convert it by hand (unless you have too much to convert by hand).
Software such as XML Spy can convert your SQL-based code into XML documents as well. When you have a large data set, a converter is highly recommended. According to its references, you can work with:
- ADO
- Oracle
- mySQL
- SQL Server
- ODBC
- Sybase
- MS Access
- Excel
- Tab Delimited, CSV
There are other converter tools such as Rustemsoft's XML Converter or XML Buddy (Eclipse plugin) from Bocaloca software. These applications can export your data and also provide you with an XML Schema or DTD (document type definition) file if desired. These applications are very handy and make the process of converting your file or database to XML much more user-friendly.
Step 2
If you are at this step, you must convert it by hand. In the real world, you may not actually even have it originally in Microsoft Excel. Let's take a basic text document and convert it to XML. But first things first: how about a quick review of the basic rules of XML?
XML - The Extensible Markup Language is a text-based, cross-platform language that enables you to store data (like addresses in an address book) in a structured manner. The XML document is expected to have correct syntax. Therefore, when making XML documents, they should be well-formed. A well-formed document has the following:
- Closed tags (
or ) - An element's attribute must be enclosed in double quotes (
) - XML is case sensitive. In other words, the beginning and ending tags should use the same case.
Here is a basic list of 17th century Dutch painters.
Rembrandt Van Rijn, 1606-1669, Night Watch
Hendrick Avercamp, 1585-1634, Winter
Jan de Bisschop, 1628-1671, The Oostpoort
As you can see, the data is separated by commas, also known as a comma-delimited file. Each line is a separate chunk of data. Each chunk has the painter's name, birth to death year, and finally one of their paintings. Therefore, we need to build an XML file with the following structure:
- Painter's Name
- Painter's Year of Birth
- Painter's Year of Death
- Painter's Painting
Step 3
With this format in mind, we can create an XML file. Our root element will be called painters since we have a list of painters.
Rembrandt Van Rijn
1606
1669
Night Watch
Hendrick Avercamp
1585
1634
Winter
Jan de Bisschop
1628
1671
The Oostpoort
Each painter becomes a sub-element of painters called painter. Each of our painters has two dates associated with them as well as a painting. Therefore, we are going to make the name, dates, and painting child elements of the element painter. They are going to be called name, yearofBirth, painting, and yearofDeath. With this file, we have our converted data ready to be used as we see fit.
Convert a file to XML format
By Howtodotips
Convert a file to XML format : Multi-thousand tips to make your life easier.