Sample code for converting xml into html using xlst

Source: Internet
Author: User
Tags xslt
This article describes the sample code for converting xml into html using xlst. it has some reference value. let's take a look at the xml file.

 
     
     
      
         
    
     
What is Zhuge Liang's surname?
          
            
     
      
Various
             
     
      
Zhuge
             
     
      
Zhuge Liang
             
     
      
Bright
           
    2      
        
     
    
      
         
    
     
What are the three kingdoms?
          
            
     
      
Wei Guo
             
     
      
Wu Guo
             
     
      
Liaoguo
             
     
      
Shu Guo
           
    1, 2, 4      
        
     
      
      
         
    
     
Liu Bei established Shu Guo?
          
            
     
      
0
             
     
      
1
           
    1      
        
     
        
      
         
           三国里的五虎上将是指关羽,$_4.1_$,$_4.2_$,$_4.3_$,赵云。           
    Zhang FeiWei YanMa Chao            
            
             
             
           
        
     
    
      
         
    
     
Why did Zhuge Liang fail to unify the three kingdoms?
    Because Wei has unified the Three Kingdoms.      
        
     
  
 


Xslt file

 
     
    
          public static string ChangeTextBox(string content)    {              // Define a regular expression for repeated words.        Regex rx = new Regex(@"\$_\S\S\S_\$",          RegexOptions.Compiled | RegexOptions.IgnoreCase);        // Find matches.        MatchCollection matches = rx.Matches(content);        // Report on each match.        foreach (Match match in matches)        {            string word = match.Value;                       content=content.Replace(word,"<input name=\""+word.Substring(2,word.Length-4)+"\" type=\"text\">");        }        return content;            }      
    
                    
   <Xsl: value-of select = "@ Title"/>                    
   

Name: Student ID: Start time: Time: Total score:

. (Total Question, Points)

YN


Generate html

      Cold exam system        

End exam of junior high History

Name: Xiaohan Student No.: 041124096 start time: 120 Total score: 100

I. multiple choice questions. (1 question in total, 20 points)

1. what is Zhuge Liang's surname?

  • A.Various
  • B.Zhuge
  • C.Zhuge Liang
  • D.Bright

II. multiple choice questions. (1 question in total, 20 points)

1. what are the three kingdoms?

  • A.Wei Guo
  • B.Wu Guo
  • C.Liaoguo
  • D.Shu Guo

III. answer questions. (1 question in total, 20 points)

1. Liu Bei established Shuguo?

YN

IV. fill in blank questions. (1 question in total, 20 points)

1. generals of the five tigers in the Three Kingdoms refer to Guan Yu,,,, Zhao Yun.

V. short answer. (1 question in total, 20 points)

1. Why did Zhuge Liang fail to unify the three kingdoms?




The above is the details of the sample code that uses xlst to convert xml into html. For more information, see other related articles in the first PHP community!

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.