Combine the database with XML to reduce the server

xiaoxiao2021-03-06  71

Combine the database with XML to reduce the server

Date: 2002-12-22 16:47:36 Source: - Author: - Today, the database has become the soul of the site, it can be said, there is no centralized data management is not really a real website. And the ASP plus database, has become the mainstream mainstream, the user logs in, the forum, the message book has become the place where they use Wuzhi, and it can be used by 51 files. Now it is possible to use 2 files. But the ASP adds the database, but not perfect, especially frequently with the server.

For example, according to the ASP database program, we can simplify the job of the dedicated webmaster into two files: a database file, record all the chapters of the novel; another ASP file, used to read the content of the database; When you click on "Next chapter", you can browse the next chapter ... it is true, this seems to be very intuitive, but not, every time we browse the next chapter, our browser will automatically I consciously visited a database, so when some visits were read patiently, our database had been intimate with it 49 times. If there is N 49 times at the same time? Who can guarantee that your server still causes all requests? In particular, some of the phenomena that provide search data, the website displayed, the server is overwhelmed, because the query results have n pages, indicating that the visitors are required to connect the server to play n times.

If you say "N times, n times, it doesn't matter", then you should immediately click on the browser "back" because I will talk about some garbage content. Of course, if you want your database program to become "N page records, once interactive", welcome to continue, we will explore the integration of XML and databases.

In fact, XML is not empty as many people think, without practical use. I don't know if you think so, but it's hard to see some websites that really apply an XML. This is a fact. Now, I have listed several cases of XML to implement, I hope to prove the use of XML and powerful:

1. 1 XML file 1 ordinary html file = 49 chapter novel display applies to those ordinary homepage spaces that do not support ASP, this case XML completely replaces the database, very classically to achieve data and typesetting . XML is completely divided with HTML.

2. 1 XML file 1 to n ASP file = message / forum applies to the ASP homepage space for file components FileSystemObject and database components, no file access and database, can do a message and forum with XML And implement all the functions of the database. (I published in this forum "The third way ----- Based on XML ASP Message Board", this technology can be searched in detail. If you are interested, you can search this article in the forum.)

3. 1 database 1 ASP file embedded in XML = "N page record, one interaction"

It can be said that these technologies reflect the essence of XML. Especially the second technology, XML fully demonstrates its own advantages - existing databases of powerful and text files (one .mdb file hundred k, one .xml file only a few K, and database file modification With expert software or corresponding ASP programs, but XML files, notepads are enough.) More exciting is that XML can throw away file access components and database components to read, and even create new files . And we will talk about "N-page records, once interactions" is more comprehensive transcendence of XML on the database. First look at the XML file below:

Hello Goodbye ftp://61.139.37.148/music/songs01/ENGLISH/ Beatles / Hellogoodbye.mp3 The Beatles You Say Yes, I Say NO Yesterday http://www.mayia.com/beatlescom/beatles/mp3/mp3/yesterday.mp3 The beatles Yesterday, all my trouplas Seemed SO FAR AWAY Try, edit this file with Notepad and save the file named Songlist.xml, then open this file with the IE browser, if there is no syntax error, ie The unique tree page of XML can be displayed in the browser. Click on the link to view the effect: XML file

This is a legal XML document, and the rules and format of the XML document are also very free. If you want to create a new XML file, just change the first line of " ", while the next label and the tag can be very casual, only follow the rules:

1. The first label must correspond to the tail label, but it can be repeated, but it is not possible. 2. Label naming rules are similar to variable naming rules such as program languages ​​such as Java / C / C , which is case sensitive. 3. One document can only have one root element, such as "" 4. The only keyword "XML", the label cannot start with these three letters. 5. If the documentation is conflict, the Mandarin XML document will not be displayed normally in the browser, and the non-legitimate XML document is also expressed.

OK, we already know how to write a legitimate XML document, the next step we will begin to explore the XML file into the HTML file and operate the data in the XML document with the VBScript scripting language. First look at the following file:

Embed HTML </ Title> </ head> <body bgcolor = "# 000000" text = "# ffffff"> # 000000 "text =" # ffffff "></p> <p><XML ID = "XMLFile"> <online play> <song> <song name> Hello Goodbye </ 歌 名> <url> ftp://61.139.37.148/music/songs01/English/Beatles/hellogoodbye.mp3 </ URL> <singer> <lyrics> You say Yes, I Say no </ lyrics> </ song> <song> <song name> Yesterday </ 歌 名> <url> http: / / www.mayia.com/beatlescom/beatles/mp3/mp3/yesterday.mp3 </ url> <singer> The Beatles </ singer> <lyrics> Yesterday, All My Troubles Seemed So Far Away </ lyrics> < / Songs> </ online play> </ xml> <script language = "vbscript"> set xml = Xmlfile.RecordsetXML.MovefirstDocument.write "first record <br>" Document.write XML ("Song Name) & "<br>" Document.write XML ("singer") & "<br>" Document.Write XML ("URL") & "<br>" Document.write XML ("lyrics") & "<br> <br> "XML.MOVENEXTDocument.write" second record <br> "Document.write XML (" Song Name) & "<br>" Document.write XML ("singer") & "<br>" Document.write XML ("URL") & "<br>" Document.write XML ("lyrics") & "<br>" </ script> </ body> </ html> Click later link to view instance: View In this HTML file, we joined a pair of <XML> </ XML> tags to embed an internal XML document. The XML document embedded in the HTML file follows the same rule as the independent XML document, but saves the declaration of the independent XML document "<? XML Version =" 1.0 "Encoding =" GB2312 "?>". In the <XML> tag, we set the XML ID: XMLFile so that the subsequent scripting language accesses the XML object.</p> <p>The "SET XML = XMLFILE.Recordset" statement creates a cursor that can access XML. This cursor is similar to the Recordset object in the ASP, which is almost exactly the same as the latter. Such as:</p> <p>When we create a data cursor named XML with SET XML = XMLFile.Recordset, we can use the following methods and properties:</p> <p>Xml.movefirst () Move to the first record XML.MOVENEXT () Move to the next XML.MovePrevious () Move to the last XML.MoveLast () Move to the last XML.BOF indicate that the cursor is in the first record before XML .Eof indicates that the cursor is the total number of XML.AbsolutePosition cursors when the cursor is the last record.</p> <p>XML.Addnew () Add a record XML.Delete () Delete a record</p> <p>For example: We want to display a song name of a song, we only need to move the cursor to the record, then use XML ("song name" to get the <song name> and </ song name> Text in the room. Very convenient.</p> <p>Ok, after understanding these contents about XML, we can start our real server to reduce the burden!</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-120293.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="120293" 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.042</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 = 'uOM4ts7RN_2FRI0gfvTuiSlEVqGajQCdrQfvqiPa6xf8pNBv_2FbY96kyzg_2BCl_2F2tBfnUtjwFxLDxqT_2BGZEpjhvUpQ_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>