Detailed description of code examples for creating address book through XML data Island and Dom

Source: Internet
Author: User
Tags dns2
Generally, if you want to provide a Address Book program for your website, you need to use CGI in combination with the background database technology, which requires a high requirement on the WEB server, it cannot even be implemented on many virtual hosts that do not provide database functions. Of course, we can also use TXT text to replace the database, but TXT text is relatively difficult to operate, we must read and judge a row, but also use a separator string to achieve field separation, complex operations cannot be performed. Generally, if you want to provide a Address Book program for your website, you need to use CGI in combination with the background database technology, which requires a high requirement on the WEB server, it cannot even be implemented on many virtual hosts that do not provide database functions. Of course, we can also use TXT text to replace the database, but TXT text is relatively difficult to operate, we must read and judge a row, but also use a separator string to achieve field separation, complex operations cannot be performed.
Now, we can use "Extensible Markup Language (xml)" to save the address book data, which reflects the advantages of XML: a structured method for displaying data, it is helpful for saving many relational data structures.

I. basic principles:
In Microsoft Internet Explorer 5.0 and later versions, we can use XML elements to create data Islands, which are XML data referenced or contained by HTML pages, XML data can be contained in HTML files or an external file. using XML data Island can save us the trouble of writing complex scripts. DOM can parse XML documents. all elements, entities, attributes, and other individuals in the documents can be represented by object models. the logical structure of the entire document is similar to a tree, the generated object model is the node of the tree. each object contains both methods and attributes. DOM provides many methods for searching nodes. With DOM, developers can dynamically create XML, traverse documents, and add (delete/modify) Document Content. APIs provided by DOM are not related to programming languages, therefore, for some interfaces that are not clearly defined in DOM standards, different parser implementation methods may be different.

2. the specific process is as follows:
1. define the XML file as follows:

      
 <中国计算机世界出版服务公司通信录>
         
  <计算机世界 contactid="2">
            
   <部门名称>
    
Computer room
            
   <电话号码>
    
139
            
   <电子邮件>
    
Fsdos@163.net
          
       
 

Save the preceding XML file as a tele. xml file, empty the field content in the preceding XML file as the initialization framework data, and save it as a newid. xml file.
2. the client loads the XML document and binds the XML file to the table in the address book through DATASRC = '# xmldso, the DATASRC attribute is actually implemented by adding # Before the ID attribute of the XML element to be processed, so we can specify the fields to be displayed in the middle of the TD element;
3. use the DOM technology to add or delete records to or from the address book;
4. connect to the server through the xmlhttp protocol and save the XML document.

III. xml dom Programming:
1 client dom.htm 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: info-contact@alibabacloud.com 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.