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

XML File: What is it and how to open it? Using XML in Flash "3.XML will be compatible with SGML."

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 a text file in which the commands of the universal extensible markup language (Extensible Markup Language) are written, which is quite reminiscent of the well-known tool HTML markup.

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 in World Wide Web the surfer does not need to think about physically opening such information file, because even when playing a song online, the player will display all the data similar to what is 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 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 standard set Windows.

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 in top 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 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, it is enough to simply initially save the attachment in its original format in any convenient place on disk or on removable media, 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.

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 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 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 portions 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

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 .

XML language(Extensible Markup Language) was developed working group XML Working Group of the World Wide Web Consortium (W3C). Here's how its creators describe it:

"Extensible Markup Language (XML) is a component SGML... It is designed to make it easier to use SGML on the Web and perform tasks that are currently done using HTML. XML is designed to improve the use and interoperability of SGML and HTML."

This is an excerpt from the XML specification version 1.0, created by the XML Working Group in February 1998. The entire document can be found on the W3C website at http://www.w3.org/TR/REC/-xml.

XML is a markup language designed specifically for placing information on the World Wide Web, similar to the hypertext markup language HTML (Hypertext Markup Language), which initially became the standard language for creating Web pages. Because HTML language completely satisfies all our needs, the question arises: why was it needed completely? new language for the Web? What are its advantages and advantages? How does it interact with HTML? Will it replace HTML, or just improve upon it? Finally, what is SGML, of which XML is a part, and why can't SGML itself be used for Web pages? In this chapter I will try to answer all these questions.

Purpose of XML

The HTML language provides a fixed set of elements that you can use to place components on a typical Web page. Examples of such elements include headings, paragraphs, lists, tables, images, and links. For example, HTML is great for

creating personal home page. Below is the description of the home page in HTML codes:

Home Page

Michael Young's Home Page

Welcome to my Web site!

Web Site Contents

Please choose one of the following topics:

  • Writing
  • Family
  • Photo Gallery

Other Interesting Web Sites

Click one of the following to explore another Web site:

  • "1. XML should become the language of direct use on the Internet."

    As you might have guessed, XML was designed primarily for storing and distributing information on the Web.

    "2. XML will support a large number of applications."

    Although its primary purpose is to distribute information on the Web through servers and browser programs, XML is also designed to be used by other programs. For example, XML is used to exchange information between financial programs, to distribute and update software products, and to write voice scripts when delivering information over the phone.

    "3.XML will be compatible with SGML."

    XML is a specialized branch of SGML. The advantage here is ease of adaptation software SGML for working with HTML.

    "4. It will be easier to write programs that process XML documents."

    To make practical use of XML, it is necessary that it be fairly easy to write browsers and other programs that process XML documents. In fact, the main reason for separating XML from SGML was the ease of writing programs to process XML documents.

    "5. Quantity additional functions in XML should be minimal, and ideally zero.”

    The minimal number of additional functions in XML makes it easy to write programs to process XML documents. The abundance of additional plug-in functions in SGML was the main reason that determined its practical unsuitability for representing Web documents. Additional SGML features require overriding delimiter characters for tags (usually ) and skipping the end tag so that the processor detects the end of the element. When strictly writing an SGML document processing program, it is necessary to take into account the possibility of all additional functions, even if they are rare.

    "6. XML documents should be clear and understandable to the user."

    XML is intended to become the lingua franca (universal language) for exchanging information among users and programs around the world. According to this concept, users, as well as specialized programs, should be able to create and read XML documents. Accessibility and transparency for the user distinguish XML from most other formats used in the construction of databases and text documents.

    The user can easily read the XML document because it is described in plain text and has a logical hierarchical tree structure. You can simplify XML documents by assigning meaningful names to elements, attributes, and objects, and by adding useful comments. (This will be discussed later in this chapter.)

    "7. XML development should be completed fairly quickly."

    XML will only become a widely accepted standard if programmers and users accept it. This standard must be created before society accepts the alternative standards that are increasingly being created by software companies.

    "8. XML should be formal and concise."

    The XML specification is written in a formal language used to represent computer languages, with a notation known as Extended Backus-Naur Form (EBNF). This formal language, although quite difficult to understand, is devoid of ambiguity and greatly facilitates the writing of XML documents, and especially programs for processing them.

    "9. XML documents will be easier to create."

    The practical use of XML as a markup language for Web documents simplifies not only the writing of processing programs, but also the process of creating XML documents themselves.

    "10. The compressed form is not important in XML markup."

    In accordance with point 6 (the XML document must be clear and understandable to the user), the XML markup should not be overly compressed so as not to conflict with the specified purpose.

    Standard XML Applications

    You can use XML for more than just describing a single document. An individual, company, or standards committee can define the required set of XML elements and document structure to be used for a particular class of documents. Such a set of elements and a description of the document structure is called an XML application or an XML dictionary.

    For example, an organization might define an XML application to create documents describing molecular structures, human resources, multimedia presentations, or containing vector graphics. At the end of the chapter is a list of some common XML applications that have already been created and applications that are planned to be created.

    An XML application is typically defined by the creation of a document type descriptor (DTD), which is a valid component of the XML document. A DTD is built on a database schema: it establishes and defines the names of elements that can be used in a document, the order in which elements can appear, the attributes of elements that can be used, and other features of the document. To actually use an XML application, you typically include its DTD in your XML document; Having a DTD in a document limits the elements and structures you will use to ensure that your document meets the standards of that application. The XML document definitions discussed earlier in this chapter did not include DTDs. You'll learn how to define and use DTDs in Chapter 5.

    The benefits of using standard XML applications when developing your documents are that you can share the documents with all other users of the application, and the document can be processed and displayed using software that has already been built for the application.

    XML applications that improve the quality of XML documents

    In addition to XML applications for describing specific document classes, there are several XML applications that you can use within any type of XML document. These applications make document creation easier and improve its quality. Below are examples of such applications.

    • Extensible Stylesheet Language (XSL) allows you to create powerful stylesheets using XML syntax.
    • XML Schema allows you to develop detailed schemas for your XML documents using standard XML syntax, a more powerful alternative to using DTDs.
    • XML Linking Language (XLink) gives you the ability to link your XML documents. It supports multiple destination links and other useful features, providing greater freedom than HTML's linking mechanism.
    • XML Pointer Language (XPointer) allows you to define flexible target links. When XPointer and XLink are used together, you can link to anywhere in the target document - not just jumps to specific points.

    XLS will be covered in Chapter 10. Other XML applications are not yet mature and are not covered in this book. (XLink and XPointer are not supported in Internet Explorer 5).

    As you can see, XML is not only a useful tool for describing documents, but it also serves as the basis for building applications and extensions that may be in demand as the Internet evolves.

    Real Use of XML

    Although the concept of XML is quite interesting, you may be wondering how to put it into practice. This section provides a list of examples of such applications of XML, both already in widespread use and those in the future. If there are corresponding XML applications for practical use, they will be listed in parentheses. For example, you may find that the MathML XML application will allow you to format mathematical formulas.

    Link. A more complete list of current and upcoming XML applications, including detailed descriptions, can be found on the Oasis SGML/XML Web page (http://www.oasis-open.arg/cover/ocml. htmW applications).

    • Working with databases. Like traditional databases, XML can be used to assign a label to each field of information within each database record. (For example, you can tag each name, address, and phone number within your address list entries.) You can then display the data in various ways and organize search, sorting, filtering and other processing of data.
    • Structuring documents. The hierarchical structure of XML documents is ideal for marking up the structure of documents such as novels, scientific papers, and plays. For example, you can use XML to mark up a play into acts, scenes, characters, plot lines, scenery, etc. XML markup allows programs to display or print the document in the required format; find, extract, or manipulate information in a document; generate tables of contents, summaries and annotations; process information in other ways.
    • Working with vector graphics (VML - Vector Markup Language).
    • Multimedia presentations (SMIL - Synchronized Multimedia Integration Language, HTML + TIME - HTML Timed Interactive Multimedia Extensions).
    • Description of channels. Channels are Web pages that are automatically sent to subscribers. (CDF - Channel Definition Format).
    • Description of software packages and their relationships. Such descriptions ensure the distribution and updating of software products on the network (OSD - Open Software Description).
    • Application communication over the Web using XML-co-communications. These messages are independent of operating systems, object models and computer languages ​​(SOAP - Simple Object Access Protocol).
    • Sending electronic business cards via e-mail.
    • Exchange of financial information. Information is exchanged in an open and understandable format between financial programs (such as Quicken and Microsoft Money) and financial institutions (banks, public funds) (OFX - Open Financial Exchange).
    • Create, manage and use complex digital forms for commercial Internet transactions. Such forms may include digitized signatures that make them legally recognized (XFDL - Extensible Forms Description Language).
    • Exchange of job requests and resumes (HRMML - Human Resource Management Markup Language).
    • Formatting mathematical formulas and scientific information in
    • Web (MathML - Mathematical Markup Language).
    • Description of molecular structures (CML - Chemical Markup Language).
    • Encoding and displaying information about DNA, RNA and chains (BSML - Bioinformatic Sequence Markup Language).
    • Coding of genealogical data (GeDML - Genealogical Data Markup Language).
    • Astronomical data exchange (AML - Astronomical Markup Language).
    • Creation of musical scores (MusicML -Music Markup Language).
    • Working with voice scripts to deliver information over the phone. Voice scripts can be used, for example, to generate voice messages, product availability certificates and weather forecasts (VoxML).
    • Processing and delivery of information by courier services. Federal Express, for example, already uses XML for this purpose.
    • Presentation of advertising in the press digital format(AdMarkup).
    • Filling out legal documents and electronic exchange of legal information (XCL - XML ​​Court Interface).
    • Coding of weather forecasts (OMF - Weather Observation Markup Format).
    • Exchange of information on real estate transactions (RETS - Real Estate Transaction Standard).
    • Exchange of insurance information.
    • Exchange news and information using open Web standards (XMLNews).
    • Presentation of religious information and markup of liturgical texts (ThML - Theological Markup Language, LitML - Liturgical Markup Language).

    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 stored in plain 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

    Transition to new systems (hardware or software platforms) always takes a long 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 it much easier to expand or upgrade operating systems, switch 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 PDA type
    • RSS languages ​​for news channels
    • RDF and OWL for resource description and ontology
    • SMIL to describe multimedia for the web


Related publications