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!