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:
- 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).
- 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).
- A dialog box will appear XML export(Export XML) (Fig. 12.9).
- 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.
- To set additional conversion options, click the button Additionally(Advanced) (Fig. 12.10).
Rice. 12.10. Tab Data dialog box XML export
- 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
- Click OK.
- 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:
.
.
.
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
Listing 1.6. Selecting only name and weight
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:
Note that this file looks much like the original planets.xml file, except that each element
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
File extension | .xml |
File category | |
Example file | (252.17 KiB) |
Related programs | Microsoft Visual Studio 2013 JAPISoft EditiX Wattle XMLwriter MacroMates TextMate |