Using XML data island to make address Book with Dom

Source: Internet
Author: User
Tags add object data structures dns2 mail object model version client

In general, if you want to provide the site with an address book program, the need to use CGI combined with the background database technology, the requirements of the Web server is relatively high, in many do not provide database functionality of the virtual host can not even achieve. Of course, we can also use TXT text to replace the database, but txt text is more difficult to operate, we have to read a row of judgment, but also to use a delimited string to implement field separation, can not perform complex operations.
Now we can use Extensible Markup Language (XML) to store the data in the Address book, which reflects the advantages of XML: The structured approach to presentation data is helpful for saving files with many relational data structures.

First, the basic principle:
In Microsoft Internet Explorer 5.0 and later, we can use XML elements to create data islands that are referenced by HTML pages or contain XML data that can be included in an HTML file or included in an external file. Using XML data islands allows us to avoid the hassle of writing complex scripts. The DOM can parse an XML document, all individuals in a document, such as elements, entities, attributes, and so on, can be represented by the object model, the logical structure of the entire document resembles a tree, the resulting object model is the node of the tree, each object contains both methods and attributes, and DOM provides many ways to find nodes. With DOM, developers can dynamically create XML, traverse documents, add (delete/modify) document content, and Dom provides APIs that are independent of programming languages, so implementations of different parsers may differ for interfaces that are not explicitly defined in some DOM standards.

Second, the specific process is:
1. The definition XML file is as follows:

< China Computer World Publishing Service Company Communications >
< computer World contactid= "2" >
< department name > Computer Room
< phone number >139
< e-mail >

Save the XML document as a Tele.xml file, and empty the field contents in the XML document as the initialization framework data and save as a newid.xml file.
2. The client loads the XML document and binds the XML file to the table by datasrc= ' #xmldso ' in the table where the address book is placed, and the Datasrc property is actually implemented by adding a # to the id attribute of the XML element to be processed. So we can specify the field to be displayed in the middle of TD element;
3, use the DOM technology to add, delete the record operation of the address book;
4, through the XMLHTTP protocol to connect to the server, save the XML document.

Three, XML DOM programming Brief introduction:
1, Client dom.htm page:

Computer World----Communication record

Data binding for
number department name phone number e-mail
Receiveddoc.load Request ' receives XML data;
Set files=server.createobject ("Scripting.FileSystemObject")
Set Numtxt=files. CreateTextFile (Server.MapPath ("Tele.xml"), True)
Numtxt. WriteLine (replace (receiveddoc.xml, "?>", "encoding=" gb2312 "?>")) ' writes XML data to a file
Numtxt. Close
Response.Write Receiveddoc.xml

3, the actual use of the process, but also need to add a display Address Book page index.htm, in fact, is the above dom.htm simplified version, remove all add, delete, modify and save functions, Display data in table cells only with label:

Computer World----Communication record
< br>

  < Td>
# department name phone number email

The advantages of using XML data island combined with DOM technology:
1, the first, of course, is the benefits of XML itself. XML breaks the monopoly of tag definitions

Total 2 page: previous 1 [2] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.