XML Getting Started Structure and Syntax

xiaoxiao2021-03-06  108

XML Getting Started Structure and Syntax

■ Tool XML files for the XML file are the same as the HTML file, actually a text file. Obviously, everyone will immediately understand that the most common tools and HTML of the XML file are "Notepad". In addition to "Notepad", there are other more convenient tools, such as XML Notepad, XML Pro, CLIP! XML Editor, etc., a major feature of these tools is that you can check if the XML file you established meets the XML specification. However, these tools are now only English and need to pay. Of course, you can still use tools such as FrontPage, Dreamweaver, but it is not very convenient to use. As XML gradually spread, I believe that the tool for creating an XML file will also occur very well. ■ An example of an XML file Now we temporarily use "Notepad" to create our XML file. First look at an XML file: Example 1 ---------------------- < Book> XML Getting Started> Zhang 3 20.00 XML Syntax Li 4/0 author> 18.00 ----- ---------------- This is a typical XML file, and the edited file is saved as a file with .xml suffix. We can divide this file into two large parts of the file preamble (proLog) and file main body. The first line in this file is a file preamble. The line is something that an XML file must be declared, but also must be in the first line of the XML file, it is mainly to tell how to work. Among them, Version is the version number indicating that the standard used by this XML file must be; eNCoding indicates the character type used in this XML file, which can be omitted, when you save this declaration, the back character code must be Unicode The character code (recommended should not be omitted). Because we use the GB2312 character code in this example, ENCODING is not omitted. There are also some statements in the file preamble part, we will introduce later. Both the rest of the file belong to the file body, the content information of the XML file is stored here. We can see that the file main body is consisting of started and end Control tag, this "root element" called XML file; is directly under the root element Child elements; in , there are , <>>, . The currency unit is a "attribute" in the Element, "Renmin" is "attribute value". This sentence is the same as HTML, is a comment, in the XML file, the comment section is placed between the "" tag. Everyone can see that the XML file is quite simple. Like HTML, XML files are also composed of a series of tags, but the tags in the XML file are our custom tags, which have a clear meaning, we can explain the meaning of the content in the mark. ■ The syntax of the XML file has a preliminary impression on the XML file, we will talk about the syntax of the XML file in detail.

Before speaking, we must understand an important concept, which is an XML parser (XML PARSE). 1. The main function of the XML parser parser is to check if the XML file has a structural error, peeled off the mark in the XML file, read the correct content to give the next step application process. XML is a markup language for structured file information. In the XML specification, there is a detailed rule for how to mark files, the parser is based on the software written according to these rules (multi-purpose Java writes). Like HTML, in the browser, there must be an HTML parser so that the browser can "read" all the web pages composed of HTML tags, and display them in front of us. If you have a browser's HTML parser read the tag, it will return to us error message. Since the current HTML tag is actually quite confusing, there is a large number of irregular markers (some web pages can be displayed normally, and the Netscape Navigator is not line), so from the beginning, XML designers strictly specify XML syntax And the structure, the XML file we have written must follow these regulations, otherwise the XML parser will show you the error message without your love. There are two XML files, one is a Well-Formed XML file, one is a validating XML file. If an XML file meets some of the relevant definitions in the XML specification, it is not called Well-Formed when using DTD (file format definition - after detail). And if an XML file is Well-Formed, and the syntax in the DTD is correctly used correctly, then this file is Validating. Corresponding to two XML files, there are two XML parsers, one is a Well-Formed parser, one is a validating parser. In IE 5, the Validating parser is included, and the Validating parser can also be used to parse the Well-Formed XML file. Check if it satisfies the condition of Well-Formed. We can open the first XML file you just edited with the IE 5 or more version of the browser. Everyone may ask why the display is the same in the browser and my source file? That's right, because for XML files, we are 鼋龉 匦   荩    允 问 墙 墙 墙 墙 墙 鳦 墙 墙 鳦 墙 鳦 鳦 鳦 墙 鳦 墙Here, we have not defined its CSS or XSL file to this XML file, so it is displayed in the original form. In fact, for electronic data exchange, just an XML file, if you want to display it in some form, we must edit the CSS or XSL file (this problem will be discussed later). 2.Well-factoryD XML file We know that XML must be Well-Formed, can be parsed by the parser correctly, displayed in the browser. So what is a Well-Formed XML file? There are mainly a few criteria, we must satisfy them when you create an XML file. First, the first line of the XML file must be that the file is an XML file and the XML specification version it uses. Other elements or comments cannot be available in front of the file. Second, there is only one root element in the XML file. In our first example, ... is the root element of this XML file. Third, the tag in the XML file must be turned off correctly, that is, in the XML file, the control tag must have the corresponding end tag.

Such as: Mark must have a corresponding end tag, unlike HTML, the end tag of some tags can be available. If you encounter a self-into which a self-contained unit is encountered in the XML file, it is similar to those of the , if the device is written when the element contains attributes: . Fourth, the mark must not be cross. In the previous HTML file, you can write: xxxxxxxx , and tags have mutually overlapping areas, and in XML is strict It is forbidden to mark the interleaved way, and the mark must appear in regular order. Fifth, attribute values ​​must be used "". "1.0", "GB2312", "Renminbi" as in the first example. It is all used "", it cannot be missed. Sixth, the control mark, instructions and attribute names are subject to case sensitive. Unlike HTML, in HTML, like and of the marker meanings, in XML, similar , or such a mark is different. Seventh, we know, in the HTML file, if we want to browser, we will display what we entered, you can put these things in

  or  </ xmp> Middle in the middle. This is essential for our webpage we create HTML teaching because the source code of HTML is displayed in the web page. In XML, to implement such functions, you must use the CDATA tag. The information in the CDATA tag is transmitted to the application by the parser, and any control tag in this segment information is not resolved. The CDATA area is: "<! [CDATA [" is the end tag with "]]>" as the start tag. For example: The source code in Example 2, except "<! [Cdata [" and "]]>" symbols, the rest of the content parser will be handled to the downstream application, even if the beginning and end in the CDATA area Blank and wrap characters, etc., it will also be transferred (note that CDATA is a capital character). Example 2 <! [Cdata [flying XML >>>>>, :-) )OOO <<<<<<]]> Eighth, XML processing blank characters and HTML are different. HTML standard regulations, regardless of how many blanks are treated as a blank; and in XML, blank other than all markers, parsers must be faithfully handed over to the downstream application processing. In this way, we sometimes abandon the shrinking habits when writing HTML files, because the constituent spaces, the parser is also handled.如: 张 三 </ author> and <author> Zhang 3 </ author> The above is different for the parser (the latter is in the <author> </ author> tag, in addition to Zhang San this character) In addition, two linear symbols before "3") are also included. Therefore, the parser will have different processing results to pass the information to the application after removing the mark. If we want to tell the XML program, the blank in the mark has a clear meaning, don't take it casually (as in some poems, the space has its specific significance), you can add an XML built-in property in the mark --XML : Space.</p></div><div class="text-center mt-3 text-grey">
转载请注明原文地址:https://www.9cbs.com/read-99061.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="99061" 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.047</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 = 'sMZfZUd5mJ8LHE1989W0W7A7GXSdzunSgAo8aFnLL7hVBp9hC2PVe8hCXqpVLOpw3XGb_2Fpbv6NU0pdN9gN2wCg_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>