Use xmldom to generate static html pages on the server

Source: Internet
Author: User
The page data generated by the server usually needs to generate a static htm page to increase the access speed. Generally, you can use fso to generate static htm pages. However, if fso is disabled or you do not have the permission to use fso, you need other solutions. using xmldom and its save () method is a good solution. in addition, if the data is in xml format, using save () is faster than using fso, and the code reuse rate is also high. The page data generated by the server usually needs to generate a static htm page to increase the access speed.
Generally, you can use fso to generate static htm pages.
However, if fso is disabled or you do not have the permission to use fso, you need other solutions.
Using xmldom and its save () method is a good solution.
In addition, if the data is in xml format, using save () is faster than using fso, and the code reuse rate is also high.

Note that:
The default encoding method is "uft-8" when the xmldom. save () method is called ".
If the output type of a specified document is "html", the encoding type cannot be specified. when the data contains Chinese characters, the stored htm data is found, all Chinese characters are garbled.

Solution:
Generally, browsers do not interpret html pages other than htm tags.
A. specify the output document type as "xml"
B. specify the encoding (encoding = "gb2312 ")
C. specify the retention indent format (for ease of reading)

Examples:/*** create. asp ***/<% dim cXMLFile, cXSLFiledim oXML, nvidim oOutputdim cHtmLFile, delimiter = "book.htm" 'chtmlfile = "book _" & replace (now ,": ",""),"-",""),"","")&". htm "cXMLFile = Server. mapPath ("book. xml ") cXSLFile = Server. mapPath ("book. xsl ") cOutputFile = Server. mapPath (cHtmLFile) Set oXML = Server. createObject ("Microsoft. XMLDOM ") oXML. async = falseoXML. load (cXMLFile) Set oXSL = Server. createObject ("Microsoft. XMLDOM ") oXSL. async = falseoXSL. load (cXSLFile) Set oOutput = Server. createObject ("Microsoft. XMLDOM ") Call oXML. transformNodeToObject (oXSL, oOutput) oOutput. save (cOutputFile) Set oXML = NothingSet oXSL = NothingSet oOutput = NothingResponse. redirect (cHtmLFile) %>/*** book. xml ***/
 
 
 
        
   <书名>
    
XML-based asp.net development
      
   <定价>
    
42
         
   <作者>
    
Dan Wahlin/Wang Baoliang
   
  
        
   <书名>
    
UML modeling technology for XML applications
         
   <定价>
    
32
         
   <作者>
    
David Carlson/Zhou Jing Hou Yimeng Shen Jinhe, etc.
   
  
        
   <书名>
    
Extreme Programming
         
   <定价>
    
70
         
   <作者>
    
Giancarrio Succi/Michelin Marchesi/Zhang Hui)
   
  
        
   <书名>
    
Design Patterns
         
   <定价>
    
38
         
   <作者>
    
Erich Gamma/Richard Helm/Ralph Johnson/John Vlissides
   
  
 /*** Book. xsl ***/
 
 
  
  
  
   
   
           
   
      
   
            
   
   
 

The above section uses xmldom to generate static html page content on the server side. For more information, see PHP Chinese website (www.php1.cn )!

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.