Convert file to xml. Conversion to XML format. How to Convert XML File to Excel

Let's look at the procedure for converting a database object into XML format:

  1. In the database window, select the required object by left-clicking and select the command File, Export(File, Export) or right-click on the object and select the command from the context menu Export(Export).
  2. A dialog box will appear Export an object(Export To). In the dropdown list Types(Save as type) select the element XML Documents(XML Documents). In field File name(File name) enter the name of the HTML document and click the button Export(Export).
  3. A dialog box will appear XML export(Export XML) (Fig. 12.9).
  4. This dialog box contains three checkboxes for the three components of an XML document: data, data schema, and data presentation. (For more information, see the “XML Format in Microsoft Office 2002” section of this chapter). Select the check boxes for the parts of the XML document that you want to export. For example, if you select the checkboxes simultaneously data (XML)(Data (XML)) and data schema(Schema of the data), the data schema will be exported and saved separately from the XML data file, in an XSD file. For tables, you can export only the data or its structure, or the data and structure together and not export the table view as a Web page: checkbox data presentation(XSL) (Presentation of your data (XSL)) can be removed.

Rice. 12.9. Dialog window XML export

Comment

The Data (XML) check box should only be cleared if you only want to export a new representation of the database object and the data has previously been exported to an XML file. Otherwise, when you open the resulting Web page, you will receive a message about an error connecting to the data source, and the page itself will be almost empty.

  1. To set additional conversion options, click the button Additionally(Advanced) (Fig. 12.10).

Rice. 12.10. Tab Data dialog box XML export

  1. In addition, this dialog box contains two more tabs for the two remaining components of the XML document: data schema and data representation. On each of these tabs, you can select a checkbox that allows you to export the corresponding part of the XML document, specify the path and name of the file in which this part of the document will be saved, and set some additional parameters:
    • on the tab Data(Data) using dropdown list Encoding(Encoding) you can select the encoding to save the page contents;
    • on the tab Scheme(Schema) you can use radio buttons to choose whether to export the data structure to a separate XSD file or embed it in an XML file along with the data;

Rice. 12.11. Account report opened in the database

  • on the tab Presentation(Presentation) using the switches, you can select the presentation format of the Web page: HTML processed on the client side or ASP server side. If the exported object contains pictures that you want to include in the resulting document, you can specify the name of the folder in which they are located. On the same tab there is a field for entering the name of the XSL file with a description of the page design. If the specified file does not exist, Access 2002 will create an XSL file describing the external representation of the document (the developer can later use this as the basis for developing an XSLT file to convert the XML document to another format).

If you need more information about representing data in XML format, click the button Reference(Help). Information about developing and converting XML documents can be found on the Microsoft Developer Web site: http://msdn.microsoft.com/.

Rice. 12.12. The Invoice report, the data of which is converted to XML format, opened in Internet Explorer

  1. Click OK.
  2. If the proposed transformation parameters have not been changed, three files will be created as a result: XML - with data, XSL - with styles, and HTM - with a representation of the converted object. To open the resulting Web page, you need to open an HTM or ASP file in Internet Explorer, depending on which presentation format you selected.

Unfortunately, subforms and reports, and associated graphics, will not be added to the XML document obtained from the database object. However, simple objects with embedded graphics exported to XML will look almost exactly the same as the original ones in Access. You can verify this by comparing, for example, the original and the Invoice report converted to XML format from the Northwind database (Figures 12.11 and 12.12).

If there is a lot of data in the data source of the selected object, loading the Web page into the Internet browser may take a significant amount of time.

Comment

Since the data itself contained in such a Web document is stored entirely in the XML file, there is no need to access the database from which the data was originally taken (as, for example, is the case when converting a report to XML format). This means that that to provide access to such a document, it is enough to place only the mentioned set of files containing a description of this document on the Web server. On the other hand, this means that changing the data in such a document is only possible using applications that have access to the XML file and are able to perceive it. this format.

XML to XML Conversions

XML-to-XML transformations are sometimes thought of as SQL for the web because they allow database queries to be run on XML documents. Below is an example. The planets.xml file we use contains quite a lot of data about each planet:


Mercury
.0553
58.65
1516
.983
43.4

Venus
.815
116.75
3716
.943
66.8

.
.
.

What if we only needed a subset of this data - for example, the name and mass of each planet? In database terms, planets.xml is a table, and we want to create a new table containing a subset of the data from the first one. In databases this is done using the SQL language, and for XML documents we can use XSLT.

Listing 1.6 shows a new version of the planets.xsl file that does the required transformation: only the name and mass of each planet are selected and sent to the output document. In particular, note that we are doing an XML-to-XML transformation, so I'm using the element , whose method attribute is set to "xml" (in fact, the output data type is usually XML, but if the XSLT processor sees the tag , it usually generates HTML by default).

Listing 1.6. Selecting only name and weight


xmlns:xsl="http://www.w3.org/1999/XSL/Transform">























C:planets>java org.apache.xalan.xslt.Process -IN planets.xml -XSL planets.xsl -OUT new.xml

This is what the resulting XML document, new.xml, looks like:


Mercury
.0553(Earth = 1)

Venus
.815(Earth = 1)

Earth
1(Earth = 1)

Note that this file looks much like the original planets.xml file, except that each element Contains only elements And . This way we were able to obtain a subset of the original XML document data.

Of course, any number of these kinds of XML-XML transformations can be performed. You can manipulate the data in an XML document to create entirely new XML documents. For example, you can take an XML document containing student names and grades and create a new document that displays grade averages. XSLT has many built-in functions that allow you to work with data in this way, which we'll look at in Chapter 8.

Announcement

XML Document File Format

Created as a format for storing text data, XML is a document that is understood not only by humans, but also by machines. XML is a platform-independent language that was created to store various types of data. Being simple and easy to use, this language is not inferior in popularity to the HTML language. It is also quite common on the Internet. The fact that XML files can be easily edited with simple text editors only increases its popularity.

Technical information about XML files

An XML document is a sequence of characters in which each Unicode character can be found in each individual document. This Unicode character code that makes up an XML document is divided into tokens and text content based on simple syntax rules. This format has an important advantage over HTML: XML supports arbitrary placement of tags to clearly define the data that such tags cover.

Additional information about the XML format

I'll tell you a quick way to create an xml file from an excel table!

XML documents are a very strong and powerful thing. With one XML file you can fill your website with information in a matter of seconds! After all, all modern engines (CMS) have the ability to import from an XML file. So what am I talking about?

As you know, *.xls formats (*.xlsx in Office 2007) are Microsoft Office Excel formats. The 2003 office is a thing of the past, there is already 2010, but I work on 2007, and therefore I will talk based on it. Let's go!

1. Go to the Microsoft website and download the add-on for working with XML. Download Excel 2003 Add-in: XML Tools Add-in. It doesn't weigh much, 397 KB.



2. Install it on your computer. There is nothing difficult to install. By default, the add-in is installed here: c:\Office Samples\OfficeExcel2003XMLToolsAddin

3. Now open Excel, go to the menu and select “Excel Options”.

4. In the window that appears, on the left, select the “Add-Ins” item, and at the bottom of the window, click on the “Go...” button.

5. A new window will open in front of you, in which you need to click the “Browse...” button. What it looks like is shown below.

6. Now you need to find the installed XmlTools add-on (see). Select it and click OK!

7. If you did everything correctly, you will see the following window! Feel free to click OK, installation is complete!

8. You now have an add-on tab in the top menu, and an XML Tools item on the left.

We've sorted out the installation, and now let's move directly to converting (exporting) xls to xml.

1. To do this, open the file with the data that needs to be distilled. Then select the first item in the drop-down menu “Convert a Range to an XML List...”

2. A small window will open in front of you, what do you need in it? There are radio buttons, No and Yes, what are they for? It’s simple, if you have a header for the data (in my case there is one), select Yes, and if you don’t have it, then No. Then click on the small rectangle in the top line.

3. Select the area of ​​data that we are converting and click on the button on the right in the window that appears. The previous window returns and click OK.

4. Your sign should change, one might say transform, for me it looks like this:

6. In the “File type” drop-down list, select XML data and click “Save”.

Congratulations, your file has been created!

I hope everything was presented in detail and clearly, but if you have any questions, write!

File extension .xml
File category
Example file (252.17 KiB)
Related programs Microsoft Visual Studio 2013
JAPISoft EditiX
Wattle XMLwriter
MacroMates TextMate