XML entry and simple application

xiaoxiao2021-03-13  183

1. XML introduction

XML represents an extendable marker language defined by the XML working group of the Global Information Network Association (W3C). The team describes the XML as follows: "Extensible Markup Language; XML) is a subset of SGML ... The goal is to allow general SGMLs to be served, received and processed on the website. Like Like HTML, XML is designed to be easy to do, and can cooperate with SGML and HTML. "This introduction is extracted from the official XML specification 1.0 version, which is the XML working group in February 1998. carry out. You can read the entire file from http://www.w3.org/tr/rec-xml W3C.

2. XML solution

The definition part of the XML solution XML is composed of the basic syntax. When you build an XML file, you can build your own elements and name any of your favorite names, rather than only those predefined elements groups that are restricted, thus reaching the extendable volume language "Extensible" characteristics. So you can almost use XML to describe all forms of files, from the music score to the database. For example, you can describe a list of books, as shown in the XML file below. The Adventures of Huckleberry Finn </ title> <author> Mark Twain </ author> <binding> mass market paperback </ binding> <pages> 298 </ pages> <Price> $ 5.49 </ price> </ book> <book> <title> moby-dick </ title> <author> Herman Melville </ author> <binding> trade paperback </ binding> <Pages > 605 </ pages> <Price> $ 4.95 </ price> </ book> <book> <title> The scarlet letter </ title> <author> Nathaniel Hawthorne </ author> <binding> trade paperback </ binding> < Pages> 253 </ pages> <Price> $ 4.25 </ price> </ book> </ inventory> Note When used to describe the database, XML has two over-have-proprietary formatts (such as Access .mdb or dbase.dbf) Advantages of format: XML is readily read by human beings, and it is based on well known, open standards. It is important to know that you must know that in this XML file (for example, in this example, the name of the element is Inventory, Book and Title) is not part of the XML definition. It's better to say that when you build a specific file, you will make these elements name. And you can select any correct name for the element (eg, List instead of Inventory, or item instead of the box). Tip When you name it for the element in the XML file, try to select a descriptive name - such as Ning Kook or Item rather than foo or bar. An advantage of an XML file is that it can be self-description, and each message can have a descriptive volume label attached to information. As you see in the previous example, the XML file is tissue uses a tree class structure, and the element inside is completely in other elements and a single top layer (root) element (in this example in this example). - This element is called a document element or root element - contains all other elements.</p> <p>The structure of this example XML file can be drawn as follows: so you can quickly use XML to define class structured files, such as books, chapters, sections, and different levels of sections, as mentioned above.</p> <p>3. XML's official goal</p> <p>The official target of XML next describes the ten design objectives of the XML elaborated in the official XML specification in the W3C website (http://www.w3.org/tr/rec-xml): 1. XML Should be used directly on the Internet. As you have seen in this chapter, XML is mainly designed to store and transfer information on the website. 2. XML should support a variety of different applications. Although the primary purpose of XML is to transmit information through the server and browser program on the website, XML is also designed to use software for other types. For example, XML has been used to inter-financial information, distribute and update software, and is used to write sound script so that you can transfer through telephone. 3. XML should be compatible with SGML. As explained before, XML is a set of special uses of SGML. The advantage of this feature is that the SGML software tool can easily join and XML work together. 4. You should easily write a program that processes the XML file. If XML is able to be able to be widely implemented, the browser and other programs responsible for processing XML files should be easily written. In fact, the main reason for the XML subset of SGML is to write inconvenience to handle SGML file programs. The design objectives mentioned later are mainly to support this fundamental target. 5. The number of selective functions in XML should be maintained at minimum, and ideal is zero. Use the minimum number of selective features in XML to make developers to write programs to process XML files easier. A rich selectivity in SGML is the main factor of SGML is considered to be unable to define a website file. These selective SGML features include redefining the qualified characters in the volume marking (generally "<" and ">") and when the handler can indicate that the element is ended there, the end tag can be omitted. A full application for handling SGML file features, must be responsible for all selective features, even those that are not commonly used. 6. The XML file should be readily read and clearly clear. XML is designed to become a general medium for the world's users and applications. Easy-read features make people and certain software programs to read and read XML files. The readability of XML will distinguish XML from most proprietary formats used for databases and text processing files. Because the XML file is written in pure text and has a logical tree structure, people can easily read the XML file. You can choose meaningful names for your file, attribute and entity, and add useful annotations to enhance the readability of XML. (The author will explain elements, attributes, entities and annotations in the later chapters.) 7. The design of XML should be fully prepared. Of course, XML can only be able to implement it in the case where the programming staff is willing to accept it. Therefore, the standard must be completed before the ethnic group begins to accept other alternative standards, as software companies can certainly hope to quickly produce finished products. 8. The design of XML should be in format and concise. The XML specification is used to define a regular language written in a computer language, generally referred to as an Extended Backus-Naur Form (EBNF) tab. This formal language, although it is sometimes difficult to read, but it solves the problem of unclear meaning, and finally makes the XML file with (especially) XML processing software easier, which in turn promotes the possibility of XML acceptance. . 9. XML files should be easily established. In order to make XML become a label language actually applied by the website file, not just XML handlers must be easily written, and the XML file itself must be easily established. 10. Simplify the XML tag is the least important.</p> <p>In order to match the target 6 (the XML file should be easy to read and reasonable), the XML tag must not be too simple to be too simple to read. 4. Some basic rules of XML</p> <p>The file must be strictly limited to only one top element (file elements or root elements). All other elements must be set under this element. Elements must be suitably set. That is, if the element begins in another element, it must end in the same element. Each element must have a starting element and an end element. Unlike HTML, XML does not allow you to omit the end tag - even if the browser can determine where the element ends. (However, in Chapter 3, you will learn a simple volume to use blank elements - ie elements with no content.) In the starting tab, the name of the element form must be fully compliant in the corresponding end tag. name. The name of the element type is case sensitive. In fact, all the words in the XML volume label are case-sensitive. For example, the following element is not identical because the type name in the starting tab is different from the type name in the end of the label, so it is not legal. <Title> Leaves of grass </ title> <! - illegal element -></p> <p>5. A simple example of XML Sample.xml</p> <p><? XML Version = "1.0"?> <! - file name: inventory.xml -> <sample> <book> <title> the adventures of huckleberryfinn </ title> <author> Mark Twain </ author> < Binding> Mass Market Paperback </ Binding> <Pages> 298 </ pages> <price> $ 5.49 </ price> </ book> </ sample></p> <p>Application display XML file using a series table</p> <p>First build Sample.Css file book {display: block; margin-top: 12pt; font-size: 10pt} title {font-style: itAlic} author {font-weight: bold}</p> <p>Then add <? XML-Stylesheet Type = "TEXT / CSS" href = "inventory01.css"?> "</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-129115.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="129115" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.036</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'dya7MvL0Ft4fhCmVJ71D0uj1Xz9CXzAkcm7zG7Yu6kCAaaMgt_2FTzh0G4N7YqMOwQpz9UslVZz8v3CLkvJpzxeA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>