What is the xml language used for? XML File: What is it and how to open it? "9. XML documents will be easier to create."

XML is used in many aspects of web development, but its main purpose is to make it easier to store and transfer data.

XML separates data from HTML

If you need to display dynamic data in an HTML document, it will take too much time if you edit the HTML document itself every time the data changes.

WITH XML data can be stored in separate files XML. By doing this, you focus on using HTML/CSS for display and templating, and you can be sure that new data coming in will not require any changes to the document's HTML code.

XML simplifies data distribution

In the real world, computer systems and databases use data in incompatible formats.

XML data is stored in a simple text format. This ensures software and hardware independence.

This makes it easy to create data that can be used by a wide variety of applications.

XML simplifies data transfer

One of the most time-consuming problems for developers has always been and still remains the problem of data exchange between systems that are incompatible with each other.

Transferring data as XML greatly reduces the complexity of this problem, since data in this format can be read by different incompatible applications.

XML simplifies platform modification

Transitioning to new systems (hardware or software platforms) always takes a lot of time. A lot of data needs to be converted into new formats. In this case, incompatible data is often lost.

XML data is stored in text format. This makes expansion or modernization much easier operating systems, switching to new applications or browsers without the danger of losing data.

XML makes your data more accessible

Your data can be accessed not only by HTML documents, but also any other applications.

XML makes your data accessible to all kinds of "reading machines" (voice machines, news channels, etc.), making it much easier for people with vision impairments and other physical disabilities to access it.

XML is being used to create new Internet languages

Many Internet programming languages ​​have been created using XML.

Here are some examples:

  • XHTML
  • WSDL to describe available web services
  • WAP and WML as markup languages ​​for portable devices such as PDAs
  • RSS languages ​​for news channels
  • RDF and OWL for resource description and ontology
  • SMIL to describe multimedia for the web

In the operating room Windows system Most programs store their settings in the registry. However, application settings are also often used to store special files, usually located directly in directories with executable files or in subfolders. Configuration files can have different formats, including the XML format, which is the subject of this short article.

What is this XML format, what is it for and where is it used

In truth, the goals for which the XML format was created (it appeared in 1996) were, so to speak, global. XML or eXtensible Markup Language, which translates as "extensible markup language", was developed as a means of providing interoperability for the transfer of structured data between different software systems, especially those used on the Internet. This language is so universal that XML files are understood even by incompatible applications of different operating systems, which, of course, greatly simplifies the task of programmers to exchange information between software platforms.

In addition, XML is actively used in website design. Sometimes it is positioned as a more advanced and universal analogue of the hypertext language HTML markup, but these languages ​​actually serve different purposes. HTML is primarily responsible for displaying data, while XML was designed to convey and store that data. XML is also used to create new Internet languages. By the way, RSS, familiar to many, used in distribution through news channels, is based precisely on XML.

Programs for opening and viewing files in XML format

We figured out what kind of XML format this is, now let's see how to work with it. In truth, the need to edit XML files is usually faced by developers and system administrators, but let’s still assume that the same need arose for you. How to open XML file? In general, you can view it with any text editor, even Notepad, but it is much more convenient to use special programs for these purposes.

Notepad++

If you are looking for something to open XML, try Notepad++– a universal text editor designed for creating and editing code. Lightweight, fast and simple, it's ideal for working with all kinds of configuration files. The editor supports syntax highlighting, changing encoding, there is a powerful built-in search for various parameters, in a word, everything that a programmer and not only him needs.

XMLPad

Unlike Notepad++, XMLPad is a highly specialized editor. This is exactly what you can and should use to open the XML format, since it was created specifically for working with files of this type. In addition to viewing and editing XML documents, the XMLPad editor supports document validation and inspection, conversion to DTDs, importing data from HTML, and much more. As expected, the application has syntax support and a search and replace tool. One of the features of the program is the presence of a built-in mini-browser for opening URL links.

For those who are more serious about learning web languages, we can offer an advanced and at the same time simple and convenient XML editor on the Java platform. The program supports the creation and editing of XML, XSL, XSD and DTD files, it also has a built-in converter to scripts, an XSLT and XQuery debugger, tools for working with visual XML diagrams and many other components. Disadvantages - the program is paid, and it does not support the Russian language.

XML Marker

A good way to open an XML file is to use a simple editor XML Marker. It is not as sophisticated as Oxygen XML Editor, but it copes well with most of the tasks that a user faces when working with XML files. There is a representation of the tree structure of the document with the ability to quickly navigate to selected lines by tags, convenient navigation, full set tools for working with text data. The disadvantage of the program is that there is no Russian language.

Browsers

There is one more the simplest way, how to read an XML file, however, we are talking only about reading here. Open in Google Chrome or any other browser new tab and drag the XML file onto the browser window. The document will be presented in a structured form, with syntax highlighting, everything as it should be.

View XML files online

You can work with XML documents not only using desktop programs; it is also easy to open XML online. Here are two simple online editors for you to consider.

XmlGrid

A simple-looking but quite functional online XML file editor, available at xmlgrid.net. The service supports the creation, modification, validation and conversion of XML documents, and additionally has the function of designing site maps. The code of the edited file can be pasted into a web form from the clipboard, via a URL, or by uploading the document itself to the server. The contents of the file are displayed as a data table, in which each field is a separate cell.

XML EDITOR

You can also open an XML file online using the online XML EDITOR, which is part of the TutorialsPoint application suite, one of the largest learning resources. To use the service, go to www.tutorialspoint.com, click the “Tools” link at the top of the page, find XML EDITOR in the list of web applications and open it. You will see a simple window text editor with two columns. The left one is where code is written and edited, the right one displays the tree structure of the document. You can upload a file to the editor either from your computer or from any website by specifying the URL.

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

In this tutorial, we'll introduce you to the basics of the XML format and also 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 great experience 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 top left 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 is a more complex example of structuring.

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

This example shows what the data might look like address book 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 Database . 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

Why is this XML needed?

[Recently, in connection with the appearance of these pages, the most frequent
The question for me turned out to be: “Tell me, why is it needed at all, XML?
Isn't HTML enough for us? "Not having much time (or intelligence;) to prepare my own publications, and also deeply respecting the classics, I preferred to quickly translate an excellent article on the title subj
- perhaps this is the first episode of the series "to help" ]

Jon Bosak, Tim Bray
XML and the Second-Generation Web
from Scientific American, May 1999

Give people a couple of tips, and they'll figure out the rest on their own. Looking at the page, where larger blocks of text are divided into smaller ones, everyone quickly realizes that this is the beginning of an article. Looking at the grocery list, you can quickly guess that these are “instructions” for visiting the store. When you see the columns of numbers, you understand that this is a bank account.

Computers are not yet that smart - all this has to be conveyed to them exactly - what exactly they must deal with and what is required of them for this. It is for this purpose - to make information self-describing - that it was invented new language

document markup - Extensible Markup Language (XML). These easily pronounced changes (a “self-described” document, a change in the rules of communication with computers) carry enormous potential - the role of the Internet from an information delivery medium begins to expand to other types of human activity. Indeed, since its approval by the W3C in 1998, the XML specification began to penetrate everywhere like wildfire - into industry and science, into the production of goods and medicine.

Enthusiasts hoped that XML would provide an opportunity to solve a number of global problems of the Web. These problems are known: firstly, the Internet, a super-fast network, often behaves worse than a turtle; and secondly, although almost all the information is available on the Internet, it is often maddeningly difficult to find something necessary there.

Both of these problems are caused mainly by the nature of the main language of the Web - HTML. And while HTML's success over other electronic publishing languages ​​ever proposed is obvious, HTML is too sparse: it essentially just tells the browser how to place text, images, and buttons on a page. HTML focuses on presentation of information and is therefore fairly easy to learn, but it comes at a cost.

For example, even if your doctor is able to “extract” tests taken from your medical card into his viewer, it is unlikely that he will be able to send them over the network to another specialist in order to insert the received answer back into his database. His computer doesn't know what to do with information that is as clear to him as

bee bee

or bee bee.
The legendary Kernighan once noted that the whole trick of the WYSIWYG principle (what I see is what I get) is that when you see nothing, you usually manage to get exactly the same amount.

Those words above that are enclosed in angle brackets are called tags. There is no parsing tag in HTML, and hence its other drawback: inflexibility. Adding a new tag to a language is such a bureaucratic red tape, so lengthy that no one will bother with it. But it would be nice for every program to have its own tags, not just the one in the example with the doctor.

This largely explains the current slow pace of creation of online stores, mail order catalogs and other interactive sites. If you change the number of order units and the shipping method, and see a handful of numbers changed in the “amount” field, you will still have to ask the remote (already overworked) server to send you back a complete, newly generated page with graphics and everything else. While your own powerful computer will sit idle because it just learned something like

And , but not prices with delivery options.

Add to this the poor quality of Web search capabilities. Since there is no way to specifically mark price information, it is absolutely impossible to search the web for pages based on “price.”


Something old, something new

In principle, the solution is simple: the tags need to indicate what kind of information it is, and not what it should look like. For example, mark up the components of an order for a shirt with the tags “price, size, quantity, color,” rather than “bold, paragraph, row, column,” as suggested in HTML. Then it’s easier for the program to identify the document as an order and do the rest of the work: display this order in one form or another, put it through the accounting system, or make sure that the new shirt is delivered to your doorstep the next day.

We, the W3C working group, began developing such a project back in 1996. The idea was strong, although not entirely original. For generations, editors and printers have labeled handwritten texts notes for typesetters. Such a “markup language” developed independently until 1986, when, as a result of ten years of work, the International Organization for Standardization (ISO) introduced a system for creating new markup languages.

Called SGML (Standard Generalized Markup Language), this language description language - a metalanguage - has proven its usefulness in many large publishing systems. And even HTML got its definition through SGML. The only difficulty with SGML was that it was omnivorous - there were a lot of clever things there to minimize keystrokes, since at that time every byte counted. That's why web browsers today don't work well with it.

In creating XML, our working group stripped SGML of its husks and proposed a highly targeted and digestible metalanguage. The XML base is set of rules, guided by which, everyone can create their own markup language.


<имя пациента>These rules are chosen so that one single small program (also called a parser or syntax analyzer) can cope with the recognition of any new language. Let's look again at the example of a doctor who would like to transfer tests to a specialist. If medical professionals were to construct their own markup language from XML to encode physician notes (a number of groups have been working on the problem for a long time), then a message from a doctor to his colleague might contain something like
<аллергия на лекарство>blah blah

blah blah blah In this setting, it is no longer difficult to write a program for an arbitrary computer so that it can recognize these standardized medical records and be able to enter this literally vital important information

to your database.

Just as HTML was designed to allow anyone to read Internet documents, XML gives us an Esperanto that anyone can read and write, despite a babel of incompatible platforms. Yes, even from the point of view of an ordinary person, XML has more semantic load (unlike other data formats), because there is nothing in it that would look like unreadable text.

The nesting rule automatically enforces simplicity in any XML document, producing a structure known in computer science as a tree. Similar to a family tree, any graphic or text element of a document is the father, son or brother (parent, child, sibling) of some other element, and this relationship is always unique. Of course, trees do not describe the entire variety of data structures, but they cover most of the typical cases of computer use. In addition, trees are extremely convenient for programmers. There is no problem in writing a small piece of code to reorder transactions or display a completely understandable receipt when the receipt is represented as a tree.

The second source of XML's universal power is its reliance on new standard Unicode is a coding system that allows text to be mixed in all major languages ​​of the world. On the contrary, in HTML, as in the mass word processors, a document, as a rule, can only be in one specific language, no matter which one - English, Japanese or Arabic.
And if the program does not know the encoding of a certain language, you can forget about the document (in HTML). It can be worse: for example, due to inconsistency of encodings, programs written in Taiwan often cannot read texts aimed at mainland China. In the case of XML, if the program knows how to work with it correctly, it can handle any combination of encodings.


Thus, XML not only allows data to be exchanged between different computer platforms, but also makes it possible to overcome national and cultural barriers.

End of the World Wide Wait

To illustrate, imagine using an online travel agency to find a flight from London to New York on the 4th of July. Most likely, you will see a list several times longer than can fit on the screen. This list can be shortened by setting more precise parameters such as departure time, price or airline, but in this case you simply “load” the travel agency server with your request and have to wait for a response. However, if this long list of flights were provided to you in XML, then the bureau could accompany it with a small Java applet, with the help of which you can instantly and easily sort and filter out the unnecessary ones, without resorting to any interaction with the server.

Multiply this by millions of Web users, and the overall effect is impressive. The more online information that is tagged with industry-specific XML tags, the easier it will be to find what you're looking for. Today, an Internet search for “jobs for a stock broker” will overwhelm you with an avalanche. advertisements

, but probably there will only be a few of them about work there - mostly the work is hidden on free bulletin boards of newspaper sites that search robots do not like to work with. And now the Newspaper Association of America is creating its own ad markup language in XML, which promises to make the search process much more efficient. It doesn't matter if it's just an intermediate step. Librarians have long known ways to find something quickly - by looking not at documents, but at their compact

key descriptions

Of course, information can be obtained without searching. After all, the Web is hypertext - billions of pages riddled with hyperlinks - those underlined words that you just have to click on to be whisked away to some other page. In XML, the hyperlink mechanism is also greatly enhanced. The XML linking specification, called XLink, which the W3C is preparing by the end of the year, will allow the user to choose from multiple destinations. Another type of hyperlink will allow you to receive text or an image directly at the point of clicking, allowing the visitor not to leave the page.

Perhaps the most useful part of XLink will be the part of the specification that allows authors to resort to indirect links, sending instead of the pages themselves to some kind of summary database. So, if the author has changed the address of the page, by simply editing one entry in such a database, it is easy to update all the links leading to his page. This will help you get rid of the increasingly common "404 File" messages. Not Found", signaling a "broken" link.

The combination of more efficient processing, more precise search, and more flexible linking will revolutionize the structure of the Web and open up entirely new methods of accessing information. For users, this new Network will be significantly faster, more powerful and more useful than today's Network.


Cooperation needed

Of course, not everything is so simple.

XML allows anyone to design a new language in their own way, but creating a good language is a task whose difficulty should not be underestimated.

Coming up with a language is just the beginning: it's naive to expect the meanings of your tags to be obvious to other people until you've provided a manual for the language, and to be clear to computers until you've written programs that work with the language's tags.

And there will be such agreements, since the growing incompatibility of computer platforms results in delays in deadlines, financial losses and leads to confusion in almost all areas of activity. People want to exchange ideas and get things done, regardless of the fact that everyone has different computers - and for this to become a reality, the mutual development of private (for different areas activities) languages ​​still have a long way to go. However, the flurry of new acronyms ending in "ML" demonstrates the undeniably innovative spirit that XML has brought to science, business and education.

When creating a new XML markup language, its creators must agree on three things: what tags will be there, how they can be nested within each other, and how they should be processed. The first two points - language dictionary and structure - are now encoded using DTD (Document Type Definition). The XML standard does not oblige language developers to resort to DTDs, but most new languages ​​will apparently have DTD descriptions - this makes it easier for programmers to write programs that understand this markup and extract something meaningful from it. We will also need sets of manuals that describe the meanings of all tags in human language. For example, HTML has a DTD description, but there are also hundreds of pages of familiar HTML manuals that programmers consult when developing browsers and other programs for the Web.


Essay on style

For users, the main thing is what the program can do, and not what is written in its description. In general, people prefer that programs allow them to see XML-encoded information in a readable form. But in the XML tags itself there is no special markup indicating. how data should be presented on a screen or printed sheet.

For publishers seeking to “write once and publish everywhere,” the most important thing is to “give birth” to a publication and then “pour” it into a myriad of types of publications, both print and electronic. XML helps them in this way: content is marked with descriptive tags that are independent of the rendering environment. Next, the publisher can formalize the presentation rules in the form of so-called. stylesheets (style sheets), automatically “stylizing” his work as different devices and environment. The standard for such an XML language, developed for these purposes, is called Extensible Stylesheet Language (XSL).

Latest versions Browsers can read XML documents, select appropriate style files, and use them to sort and format information on the screen. The reader may not even realize that he is dealing with XML rather than HTML unless he notices that sites with XML are faster and easier to use.

Visually impaired people also benefit freely from XSL document publishing principles, since XSL gives them the ability to read XML in Braille or by voice. These advantages apply to others as well: for example, a traveling salesman who wants to surf the Internet from the comfort of his car would probably find it quite convenient to listen to pages with sound.

Although at first the core of the Network consisted of scientific and educational programs, today's Network is already commerce (well, or one might say, commercial expectations), storing fuel for a quick start. Everyone remembers the recent resonance caused by the surge in online sales, but needless to say how quickly businessmen interact with each other online. The flow of goods from large manufacturers is begging for automation on the network. But today's business systems rely on complex program-to-program interactions, and in practice this works very poorly, because success requires uniformity of processing processes, which is still far from achieved.

For centuries, people have successfully done business by exchanging standard documents: orders, invoices, declarations, receipts, etc. etc. The documents worked for the business, and no one required that one party involved know the inner workings of the other. Any document was shown exactly as much as it should have been shown to the recipient of the information, and no more. Apparently, exchanging documents is the most correct way to do business on the Web too. But this was not at all the task for which HTML was created.

Conversely, XML is designed specifically for the purpose of exchanging documents, and it is clear that the basis of electronic commerce will rely on agreements expressed by millions of XML documents floating on the Internet.

Thus, the XML-enhanced Web should be fast, friendly, and best place for business. Even more XML is needed by webmasters and web designers. Armies of programmers will need knowledge of new XML languages ​​"to the fullest."

And although the days of self-educated hackers [the authors meant the best sense of this word] still last, their population is already under threat.

Tomorrow's web designer must be proficient not only in the production of text and graphics, but also in the construction of multi-layered, interdependent systems based on DTDs, data trees, hyperlink structures, metadata and style components - a strong and advanced infrastructure of the second generation Web. Quite often, many users of modern computer systems and software products different types

encounter files with the extension .xml. 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 technology and programs used to create documents of this type is text file

, which contains the commands of the universal extensible markup language, which is quite reminiscent of the well-known HTML markup tool.

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

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 a certain number of elements used to describe an object in this format does not exist: as much as is needed, so much is given.

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 to view or edit it is to use any editor, even the most primitive one. 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, and then, again, select the right 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 initial launch program, and then using the file open menu (in most cases this is the combination 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 limitation on the row limit that 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 refers to standard mail 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.

Bluetooth