xml文件
<?xml version="1.0" encoding="utf-8" ?> <Paper Title="小寒考试系统" Name="大三历史期末考试" Start Time ="2008-1-28 09:00" Time="120" ScoreValue="100" Score="0"> <Student Name="小寒" Id="041124096"/> <Questions Title="单选题" ScoreValue="20" Count ="1" Score="0"> <DanXuan Id="1" Subject="历史" Chapter="第三章" D if ficulty="1" ScoreValue="20" Score="0"> <Content>诸葛亮姓什么?</Content> <Choices> <Choice Key ="1">诸</Choice> <Choice Key="2">诸葛</Choice> <Choice Key="3">诸葛亮</Choice> <Choice Key="4">亮</Choice> </Choices> <Answer>2</Answer> <StudentAnswer></StudentAnswer> </DanXuan> </Questions> <Questions Title="多选题" ScoreValue="20" Count="1" Score="0"> <DuoXuan Id="2" Subject="历史" Chapter="第三章" Difficulty="1" ScoreValue="20" Score="0"> <Content>三国是指那三国?</Content> <Choices> <Choice Key="1">魏国</Choice> <Choice Key="2">吴国</Choice> <Choice Key="3">辽国</Choice> <Choice Key="4">蜀国</Choice> </Choices> <Answer>1,2,4</Answer> <StudentAnswer></StudentAnswer> </DuoXuan> </Questions> <Questions Title="判断题" ScoreValue="20" Count="1" Score="0"> <PanDuan Id="3" Subject="历史" Chapter="第三章" Difficulty="1" ScoreValue="20" Score="0"> <Content>刘备建立了蜀国?</Content> <Choices> <Choice Key="0">0</Choice> <Choice Key="1">1</Choice> </Choices> <Answer>1</Answer> <StudentAnswer></StudentAnswer> </PanDuan> </Questions> <Questions Title="填空题" ScoreValue="20" Count="1" Score="0"> <TianKong Id="4" Subject="历史" Chapter="第三章" Difficulty="1" ScoreValue="20" Score="0"> <Content> <![CDATA[ 三国里的五虎上将是指关羽,$_4.1_$,$_4.2_$,$_4.3_$,赵云。 ]]> </Content> <Answers> <Answer Key="1">张飞</Answer> <Answer Key="2">魏延</Answer> <Answer Key="3">马超</Answer> </Answers> <StudentAnswers> <StudentAnswer Key="1"></StudentAnswer> <StudentAnswer Key="2"></StudentAnswer> <StudentAnswer Key="3"></StudentAnswer> </StudentAnswers> </TianKong> </Questions> <Questions Title=" 简答题 " ScoreValue="20" Count="1" Score="0"> <JianDa Id="5" Subject="历史" Chapter="第三章" Difficulty="1" ScoreValue="20" Score="0"> <Content>为什么诸葛亮没能统一三国?</Content> <Answer>因为魏国统一了三国。</Answer> <StudentAnswer></StudentAnswer> </JianDa> </Questions> </Paper>
xslt文件
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Trans for m" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:rules="http://www.netguy.cn/xslt" exclude-result-prefixes="rules msxsl"> <xsl:output method="html"/> <msxsl:script implements-prefix="rules" lang uage=" C# "> <![CDATA[ public static string ChangeTextBox(string content) { // Define a regular expression for repeated w ord s. 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. Substr ing(2,word.Length-4)+"\" type=\"text\">"); } return content; } ]]> </msxsl:script> <xsl:template match="Paper"> <html xmlns="http://www.w3.org/1999/xhtml" > < head > <title> <xsl:value-of select="@Title"/> </title> </head> <body> <p class="Head"> <p class="Name"><xsl:value-of select="@Name"/></p> <p class="Info"> 姓名:<xsl:value-of select="Student/@Name"/> 学号:<xsl:value-of select="Student/@Id"/> 开考时间:<xsl:value-of select="@StartTime"/> 时间:<xsl:value-of select="@Time"/> 总分:<xsl:value-of select="@ScoreValue"/> </p> </p> <xsl:apply-templates select="Questions"/> </body> </html> </xsl:template> <xsl:template match="Questions"> <p class="Title"> <xsl:number format="I."/> <xsl:value-of select="@Title"/> <xsl:text>。(共</xsl:text> <xsl:value-of select="@Count"/> <xsl:text>题,</xsl:text> <xsl:value-of select="@ScoreValue"/> <xsl:text>分)</xsl:text> </p> <xsl:apply-templates select="DanXuan"/> <xsl:apply-templates select="DuoXuan"/> <xsl:apply-templates select="PanDuan"/> <xsl:apply-templates select="TianKong"/> <xsl:apply-templates select="JianDa"/> </xsl:template> <xsl:template match="DanXuan"> <p class="DanXuan"> <p class="Content"> <xsl:number format="1."/> <xsl:value-of select="Content"/> </p> <p class="Choices"> <ul> <xsl:for-each select="Choices/Choice"> <li> <xsl:number format="A."/> <input name="{http://www.cnblogs.com/@Id}" type="radio" value="{@Key}"/> <xsl:value-of select="."/> </li> </xsl:for-each> </ul> </p> </p> </xsl:template> <xsl:template match="DuoXuan"> <p class="DuoXuan"> <p class="Content"> <xsl:number format="1."/> <xsl:value-of select="Content"/> </p> <p class="Choices"> <ul> <xsl:for-each select="Choices/Choice"> <li> <xsl:number format="A."/> <input name="{http://www.cnblogs.com/@Id}" type="checkbox" value="{@Key}"/> <xsl:value-of select="."/> </li> </xsl:for-each> </ul> </p> </p> </xsl:template> <xsl:template match="PanDuan"> <p class="PanDuan" style=" width : 300 px"> <p class="Content" style=" float :left ;width:70%"> <xsl:number format="1."/> <xsl:value-of select="Content"/> </p> <p class="Choices" style="float :right ;width:25%"> <input name="{@Id}" type="radio" value="1"/>Y <input name="{@Id}" type="radio" value="0" />N </p> </p> </xsl:template> <xsl:template match="TianKong"> <p class="TianKong"> <xsl:number format="1."/> <xsl:value-of select="rules:ChangeTextBox(string(Content))" disable-output-esc api ng="yes"/> </p> </xsl:template> <xsl:template match="JianDa"> <p class="JianDa"> <p class="Content"> <xsl:number format="1."/> <xsl:value-of select="Content"/> </p> <p class="Input"> <textarea name="{@Id}" cols="70" rows="8"></textarea> </p> </p> </xsl:template> </xsl:stylesheet>
生成html
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>小寒考试系统</title> </head> <body> <div class="Head"> <div class="Name">大三历史期末考试</div> <div class="Info"> 姓名:小寒 学号:041124096 开考时间:2008-1-28 09:00 时间:120 总分:100</div> </div> <div class="Title" xmlns="">I.单选题。(共1题,20分)</div> <div class="DanXuan" xmlns=""> <div class="Content">1.诸葛亮姓什么?</div> <div class="Choices"> <ul> <li>A.<input name="1" type="radio" value="1">诸</li> <li>B.<input name="1" type="radio" value="2">诸葛</li> <li>C.<input name="1" type="radio" value="3">诸葛亮</li> <li>D.<input name="1" type="radio" value="4">亮</li> </ul> </div> </div> <div class="Title" xmlns="">II.多选题。(共1题,20分)</div> <div class="DuoXuan" xmlns=""> <div class="Content">1.三国是指那三国?</div> <div class="Choices"> <ul> <li>A.<input name="2" type="checkbox" value="1">魏国</li> <li>B.<input name="2" type="checkbox" value="2">吴国</li> <li>C.<input name="2" type="checkbox" value="3">辽国</li> <li>D.<input name="2" type="checkbox" value="4">蜀国</li> </ul> </div> </div> <div class="Title" xmlns="">III.判断题。(共1题,20分)</div> <div class="PanDuan" style="width:300px" xmlns=""> <div class="Content" style="float:left;width:70%">1.刘备建立了蜀国?</div> <div class="Choices" style="float:right;width:25%"><input name="3" type="radio" value="1">Y <input name="3" type="radio" value="0">N </div> </div> <div class="Title" xmlns="">IV.填空题。(共1题,20分)</div> <div class="TianKong" xmlns="">1. 三国里的五虎上将是指关羽,<input name="4.1" type="text">,<input name="4.2" type="text">,<input name="4.3" type="text">,赵云。 </div> <div class="Title" xmlns="">V.简答题。(共1题,20分)</div> <div class="JianDa" xmlns=""> <div class="Content">1.为什么诸葛亮没能统一三国?</div> <div class="Input"><textarea name="5" cols="70" rows="8"></textarea></div> </div> </body> </html>
以上是使用xlst将xml转换html的示例代码的详细内容。更多信息请关注PHP中文网其他相关文章!

良好形式的XMliscrucialfordAtaExchangeBecapeparsingSiturscrectparsingandSundStandingAcrossystem.1)startwithAdeClarationLike.2)确保everyveryopentingtaghasaclopingtaghasaclosingtagosingtagandelementsareproproproproproperlynested.3)

Xmlisstillusedduetoitsstructusednature,人类可读性,以及范围的addionindererpriseEnvormentments.1)itfacilitatesdataexchangeInsectInsectorlikeFinance(swift)andHealthCare(hl7)和hl7)

RSS文档的结构包括三个主要元素:1.:根元素,定义RSS版本;2.:包含频道信息,如标题、链接、描述;3.:代表具体的内容条目,包含标题、链接、描述等。

RSS文档是一种简便的订阅机制,通过XML文件发布内容更新。1.RSS文档结构由和元素组成,包含多个。2.使用RSS阅读器订阅频道,并通过解析XML提取信息。3.高级用法包括使用feedparser库进行过滤和排序。4.常见错误包括XML解析和编码问题,调试时需验证XML格式和编码。5.性能优化建议包括缓存RSS文档和异步解析。

RSS和XML在现代Web中依然重要。1.RSS用于发布和分发内容,用户可通过RSS阅读器订阅并获取更新。2.XML作为标记语言,支持数据存储和交换,RSS文件基于XML。

RSS可以实现多媒体内容嵌入、条件订阅、以及性能和安全性优化。1)通过标签嵌入多媒体内容,如音频和视频。2)使用XML命名空间实现条件订阅,允许订阅者根据特定条件筛选内容。3)通过CDATA节和XMLSchema优化RSSFeed的性能和安全性,确保稳定性和符合标准。

RSS是一种基于XML的格式,用于发布常更新的数据。作为Web开发者,理解RSS能提升内容聚合和自动化更新能力。通过学习RSS结构、解析和生成方法,你将能自信地处理RSSfeeds,优化Web开发技能。

RSS选择XML而不是JSON是因为:1)XML的结构化和验证能力优于JSON,适合RSS复杂数据结构的需求;2)XML当时有广泛的工具支持;3)RSS早期版本基于XML,已成标准。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

Dreamweaver CS6
视觉化网页开发工具