TVs. Consoles. Projectors and accessories. Technologies. Digital TV

Xml is used for transfer. How XML is used. XML simplifies data transfer

The XML language has already attracted quite a lot of attention from developers and Internet users. Today, the number of adherents of this new technology is growing as rapidly as the number of reports about the next obstacles it has overcome on the path to universal recognition. Despite the fact that XML is very young (the international organization W3C approved the specification "Extensible Markup Language (XML) 1.0" a little less than a year ago - in early February 1998) and individual components of this language are still being finalized, new languages ​​are already appearing today , created on the basis of XML, numerous Web servers are emerging that use this technology to organize the information stored on them. The Internet world around us is once again transforming, and we can become participants in this process today

The purpose of this article is to try to show some of the capabilities of XML using specific examples and to answer a number of questions that often arise when getting to know a new language. What is XML? What are its advantages over the HTML language we are already familiar with? Can you use XML on your Web pages today? And if it is possible, then how?

At the end of the article there are links to other Internet resources, with the help of which you can also obtain more complete information on specific issues of interest to you related to the use of XML and not covered by us in this article. Complete specifications for XML and related languages ​​are available on the official W3C page -

Why do we need a new markup language?

Much simpler and more convenient than SGML, HTML language allows you to determine the design of document elements and has a certain limited set of instructions - tags, with the help of which the markup process is carried out. HTML instructions are primarily intended to control the process of displaying the contents of a document on the screen of a client program and thereby determine the way the document is presented, but not its structure. The element of a hypertext database, described by HTML, is a text file that can be easily transmitted over the network using the HTTP protocol. This feature, as well as the fact that HTML is an open standard and a huge number of users have the opportunity to use the capabilities of this language to design their documents, certainly influenced the growth of the popularity of HTML and made it today the main mechanism for presenting information on the Web

However, modern applications require not only a language for presenting data on the client screen, but also a mechanism that allows you to determine the structure of the document and describe the elements it contains. HTML has a simple set of commands and quite successfully copes with the task of describing text information and displaying it on the screen of a browser viewer. However, the displayed data itself is in no way related to the tags that are used for formatting, so parsing programs do not have the ability to use HTML tags to find the document fragments we need. Those. having encountered, for example, such a description

rose,

the viewer will know what color to display the text contained within the tags and will probably display it correctly, but it is absolutely indifferent to where in the document this tag is found, what other tags the current fragment is enclosed in, whether fragments nested in it exist, or whether the relationships between objects are built correctly. This “indifference” to the structure of a document leads to the fact that searching or analyzing information inside it will be no different from working with a continuous text file that is not broken into elements. And this, as you know, is not the most effective way to work with information.

Another significant disadvantage of HTML is the limited set of its tags. DTD rules for HTML define a fixed set of descriptors and therefore the developer does not have the opportunity to enter his own, special tags. Although new language extensions appear from time to time (today the latest version of HTML is HTML 4.0), but long haul Their standardization, accompanied by constant disagreements between the main browser manufacturers, makes it almost impossible to quickly adapt the language and use it to display specialized information (for example, multimedia, mathematical, chemical formulas, etc.).

To summarize all that has been said, it can be argued that HTML today does not fully satisfy the requirements imposed by modern developers for languages ​​of this kind. And it was replaced by a new hypertext markup language, powerful, flexible, and, at the same time, convenient XML language. What are its advantages?

XML ( Extensible Markup Language) is a markup language that describes an entire class of data objects called XML documents. This language is used as a means to describe the grammar of other languages ​​and to control the correctness of documents. Those. XML itself does not contain any tags intended for markup, it simply defines the order in which they are created. Thus, if, for example, we consider that to denote an element rose the document must use a tag ;, then XML allows us to freely use the tag we define, and we can include fragments like the following in the document:

rose

The set of tags can be easily expanded. If, suppose, we also want to indicate that the description of the flower should meaningfully go inside the description of the greenhouse in which it blooms, then we simply set new tags and choose the order in which they appear:

rose

If we want to plant a few more flowers there, we must make the following changes:

rose tulip cactus

As you can see, the process of creating an XML document is very simple and requires only basic knowledge HTML and understanding the tasks we want to accomplish using XML as a markup language. This gives developers the unique ability to define custom commands that allow them to most effectively define the data contained in a document. The author of the document creates its structure, builds the necessary connections between elements, using those commands that satisfy his requirements and achieves the type of markup that he needs to perform operations of viewing, searching, and analyzing the document.

Another obvious advantage of XML is the ability to use it as a universal query language for information repositories. Today, in the depths of the W3C, a working version of the XML-QL (or XQL) standard is being considered, which may in the future become a serious competitor to SQL. In addition, XML documents can act as a unique way of storing data that includes both the means for parsing information and presenting it on the client side. In this area, one of the promising areas is the integration of Java and XML technologies, which makes it possible to use the power of both technologies when building machine-independent applications that also use a universal data format for information exchange.

XML also allows you to control the correctness of data stored in documents, check hierarchical relationships within a document, and establish a unified standard for the structure of documents, the content of which can be a variety of data. This means that it can be used to build complex information systems, in which the issue of information exchange between different applications running on the same system is very important. By creating a structure for an information exchange mechanism at the very beginning of work on a project, a manager can save himself in the future from many problems associated with the incompatibility of data formats used by various components of the system.

Also, one of the advantages of XML is that XML document processing programs are not complicated and all kinds of software products designed to work with XML documents have already appeared and are freely distributed. XML is supported today by Microsoft Internet Explorer 4/0 and in beta versions of IE5. It was announced that it would be supported in subsequent versions of Netscape Communicator, Oracle DBMS, DB-2, and MS-Office applications. All this gives reason to assume that, most likely, in the near future, XML will become the main information exchange language for information systems, thereby replacing HTML. Well-known specialized markup languages ​​such as SMIL, CDF, MathML, XSL have already been created on the basis of XML, and the list of working drafts of new languages ​​under consideration by the W3C is constantly growing.

What does an XML document look like?

First Second subparagraph 1 Third Last

Rules for creating an XML document

RussiaNovosibirsk</country>

Language constructs

Data elements

rose Novosibirsk rose Novosibirsk Siberia Novosibirsk State Technical University
very good institute Novosibirsk State University
not bad either

Quite often, many users of modern computer systems and software products of various types encounter files with the .xml extension. Many people simply have no idea what kind of document this is or how to open it. Now it will be considered. At the same time, we will find out what it is and what it is needed for.

What is an XML file

Let's start, perhaps, with the fact that, from the point of view of modern computer technologies and programs used to create documents of this type, it is a text file in which the commands of the universal extensible markup language are written, which is quite reminiscent of the well-known markup tool HTML.

Typically, an XML file contains general information about an object, which is expressed descriptively (more on this later). As for the data stored in such containers, it can be databases often used for video and audio catalogs on the Internet, saved user preferences for programs and applications, as well as entire web pages.

As an example, you can take, say, an audio album of some artist. The XML file includes information about the year of release, genre, number and names of tracks, popularity, etc. However, when visiting resources on the World Wide Web, the surfer does not need to think about physically opening such an information file, since even when playing a song online in a player All data will be displayed similar to those contained in standard MP3 files in the form of ID3 tags. The information is loaded onto the track being played.

XML file type

If you look at the file, you will immediately notice that in it the properties of any object are described using tags and attributes that are set manually.

We are not talking about the basic commands of the language itself, since the average user does not need such information. The only thing that can be noted is that there is no specific number of elements used to describe an object in this format: how many are needed is specified.

How to open standard XML format

Now let's see how to open an XML file. As many have probably already understood, this is a text file, which means that the easiest way is to use any editor, even the most primitive one, to view or edit it. Yes, at least the same “Notepad” from the standard Windows set.

However, everything is not so simple here. The fact is that double-clicking a file without setting the appropriate association with any program will not open. At best, the system will offer a list of the most suitable applications. You can select a program of your choice, and at the same time check the box next to the option to constantly use the selected application for all files of this type.

You can do it differently by right-clicking on the file and then selecting the “Open with...” command, after which, again, select the desired application either from the list, or specify the location of the main executable component (most often this is an EXE file).

The third way to open an XML file is to initially launch the program and then use the file open menu (in most cases this is Ctrl + O). In this case, it is absolutely not necessary to use Notepad. Please, the file opens without any problems in the same Word application and similar ones. Even Microsoft Excel is capable of opening data in this format.

However, if there is a need to edit the XML format, then it is better to use professional utilities that support language syntax, for example, Oxygen XML Editor, XML Marker or EditiX Lite Version. Naturally, these are not all utilities that can work with the file language at the highest level. Today you can find a lot of such programs.

Now a few words about why sometimes an XML file error appears when opening. Most often this is due to a violation of the integrity of the file itself, as well as incorrect introduction of descriptive attributes or tags. Additionally, Excel has a limit on how many rows can be displayed, so in this case the data may not be complete when opened.

Possible errors when opening an XML file as an email attachment

Sometimes errors may appear when you try to open a file that is an email attachment. Most often this applies to standard email clients like Outlook Express.

The fact is that the attachment is first saved as temporary data (very often with an additional .tmp added to the main extension), and it is this that is accessed.

To avoid this situation, you simply need to initially save the attachment in its original format to any convenient location on disk or removable media, and then use the standard methods described above.

Instead of a total

As you can see, there is nothing difficult in understanding the structure and methods of opening files of this format. Here, however, the issue of creating XML data was not fundamentally considered, since to fully understand the process you need to know at least the basics of the language itself. Otherwise, I think that users will not have any difficulties with files of this format.

Extensible Markup Language (XML). These are really just text files that use custom tags to describe the structure and other functions of the document.

What is XML

XML is a markup language created by the World Wide Web Consortium (W3C) to define a syntax for encoding documents that can be read by humans and machines. It does this through tags, which define the structure of the document, as well as how the document should be stored and transported.

The easiest way to compare it to another markup language you may be familiar with is hypertext markup(HTML) used to encode web pages. HTML uses a predefined set of markup characters (short codes) that describe the format of the content on a web page.

However, the difference with XML is that it is extensible. XML does not have a predefined markup language like HTML. Instead, XML allows users to create their own markup characters to describe content, creating an unlimited and self-defining set of characters.

Essentially, HTML is a language that focuses on presenting content, while XML is a dedicated data description language used to store data.

XML is often used as the basis for other document formats, of which there are hundreds. Here are a few you may want to know:

  • RSS and ATOM describe how applications should handle web feeds.
  • Microsoft .NET uses XML for its configuration files.
  • Microsoft Office uses XML as the basis for document structure.

So, if you have an XML file, it doesn't necessarily tell you what application it is for. However, you don't need to worry about this unless you are developing XML files.

How to open an XML file

There are several ways to open an XML file directly. You can open and edit them with any text editor, view them with any web browser, or use a website that allows you to view, edit, and even convert them to other formats.

Use a text editor when working with XML regularly

Since XML files are simply text files, they can be opened in any text editor. However, many text editors, such as Notepad, are simply not designed to display XML files with their correct structure. This can be useful for quickly familiarizing yourself with the contents of an XML file. But, there are more convenient tools for working with them.


Using a Web Browser to View an XML File

If you don't need to edit the XML file, but just want to view the content, your browser can handle this task. Moreover, your web browser is most likely already configured as standard remedy viewing XML files. So double clicking the XML file should open it in the browser.

If not, you can right-click the file to find options to open it with any other application. Simply select your web browser from the list of programs.

When the file opens, you should see well-structured data. It's not as pretty as the color look you get in Notepad++, but it's much better than notepad.

Using an online editor for XML files

If you want to edit a random XML file and don't want to download a new one text editor, or you need convert xml file to another format There are several decent online XML editors available for free.

TutorialsPoint.com, XMLGrid.net and CodeBeautify.org - Allow you to view and edit XML files. Once editing is complete, you can download the modified XML file or even convert it to a different format.

For example, we use CodeBeautify.org. The page is divided into three sections. On the left is the XML file you are working with. In the middle you will find several functions. On the right you will see the results of some of the options you can choose from.

For example, in the picture below on the left is our full xml file, and the results pane shows a tree view because we clicked the Tree View button in the middle.

Use the Browse button to load an XML file from your computer or the Load URL button to retrieve XML from an online source

The Tree View button displays the data in a well-formatted tree structure in the results pane, with all tags highlighted in orange and attributes to the right of the tags.

Beatify displays your data in a neat, easy-to-read format.

The Minify button displays your data using as few spaces as possible. This function will place each piece of data on one line. This will come in handy when trying to make a file smaller, which will save some space.

Finally, you can use the XML to JSON button to convert the XML to JSON format, and the Export to CSV button to save the data as a comma separated values ​​file, or the Download button to download any changes you made to the new XML file .

Essentially, standardization makes it possible for dissimilar objects to interact with each other - a flashlight and batteries, Macromedia Flash and the multiplayer game server, and so on. Also in World Wide Web With huge amounts of data moving every second, it is critical to standardize the way data is exchanged between systems. Powerful and easy to use, XML is quickly becoming a widely accepted standard.

In this tutorial, we'll introduce you to the basics of the XML format and show you how you can use XML and XMLSocket objects in Flash. By the end of the lesson, you will learn how to organize Flash “communication” with ASP pages to register user logins; We will also create a simple chat that works in real time using a socket server.

What will be studied

In this lesson:

  • XML format
  • Sending XML data to the server and downloading it from the server
  • Creating a New XML Object
  • Using XML Object Methods, Properties, and Events
  • Establishing a connection to a socket server using Flash

The simple chat application we'll program in this tutorial will use an XML socket connection.

lead time

This lesson takes approximately one and a half hours to complete.

Lesson files

Media files:

Start files:

Lesson12/Assets/LoginRegister1.fla Lesson12/Assets/Chat1.fla

Completed projects:

LoginRegister2.fla Chat2.fla

xml basics

Although the name XML, or eXtensible Markup Language, sounds somewhat mysterious, it is not difficult to understand and master this language. In essence, XML is a way of formatting and structuring information that receiving applications can interpret and use. In fact, we all, perhaps without even knowing it, have extensive experience in structuring and organizing information. Let's take this example.

When you want to write a letter to a friend, you must structure your thoughts (information) in a format that your friend can recognize. So, you start writing words on a piece of paper, starting from the left top corner and dividing your thoughts into paragraphs, sentences and words. Of course, you could write not from left to right, but somehow in a circle, or even try to convey your thoughts with pictures, but this method will most likely only confuse your friend. And by writing a letter in a format that is familiar to your friend, you can be sure that your message will be understood - that is, the transfer of your thoughts (data, information) to the recipient of the letter will be successful.


XML is intended for the same thing - it is a format for transmitting information. If, for example, you want to send data from Flash to a web server for processing, you must first present that data in XML format. The server can then properly interpret this data and use it. Without this, the server, having received several pieces of data, would not know what to do with the first portion, what with the second, and what relation the first portion has to the second. Thanks to XML, these disparate pieces of data are given meaning, and the server can understand how to work with them.

XML, like HTML, uses tags, attributes, and values ​​in syntax, but that's where the similarities end. While HTML uses predefined tags (such as body, head, or html), in XML the user creates his own rather than choosing predefined names from a library. Let's first look at this simple XML document:

Kelly Makar Mike Grundvig Free Makar

Each XML tag is called a node ( node), a collection of data in XML format is called an XML document. Our example document has a root node, MyFriends, and three child nodes. Each XML document can contain only one root node. The first of the child nodes has a node name of Name and a node value of Kelly Makar. The word Gender in each of the child nodes is an attribute. Attributes are optional; Each node can have an unlimited number of attributes. Typically, attributes are used to contain small pieces of information that do not need to be displayed on the screen (for example, a user ID number).


As you can see in this example, tags (which we created and described ourselves) give meaning to pieces of information (Kelly Makar, Mike Grundvig and Free Makar).

The following XML document shows more complex example structuring.

Kelly Makar 121 Baker Street Some City North Carolina Tripp Carter 777 Another Street Elizabeth City North Carolina

This example shows what address book data might look like in XML format. If we had 600 people in our address book, the Person node would be repeated 600 times with the same structure.

How should you create your own nodes, your own structure? How does the recipient object (ASP page, socket, etc.) recognize document formatting? The answer is simple - the means for this must be built into the recipient object. For example, if we created an address book in Flash and want to put the information it contains into a database, we should send an XML version of our book to an ASP page (or other script page) that can parse the information and place the data in the appropriate fields databases. You must understand that this ASP page script must be designed in advance to handle the data properly. XML is better suited for transmitting information than for storing it; Therefore, it is more convenient to store our address book data in database records than in the form of an XML document. When needed, information can be extracted from the database and converted into format using a special script



Related publications