发布网友 发布时间:2022-04-23 18:44
共3个回答
热心网友 时间:2023-10-13 12:13
内容文档
命名为:XMLFile1.xml
<?xml version="1.0" encoding="utf-8" ?>
<books>
<book>
<title>C#和ASP.NET程序设计教程</title>
<author>木林森</author>
<price>38.00</price>
<pages>344</pages>
<press>清华大学出版社</press>
<publishdate>2002-1-1</publishdate>
</book>
<book>
…………
</book>
<books>
解释文档
命名为:XSLTFile1.xslt
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table border="1">
<tr>
<td>书名</td>
<td>作者</td>
<td>价格</td>
<td>页数</td>
<td>出版社</td>
<td>出版日期</td>
<xsl:for-each select="/books/book">
<tr>
<td><xsl:value-of select="title"></xsl:value-of></td>
<td><xsl:value-of select="author"></xsl:value-of></td>
<td><xsl:value-of select="price"></xsl:value-of></td>
<td><xsl:value-of select="pages"></xsl:value-of></td>
<td><xsl:value-of select="press"></xsl:value-of></td>
<td><xsl:value-of select="publishdate"></xsl:value-of></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
XML控件在.net中的引用
<asp:Xml id="Xml1" runat="server"></asp:xml>
调用过程(在vb.net中)
Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
Xml1.DocumentSource = "XmlFile1.xml"
Xml1.TransformSource= "XSLTFile1.xslt"
End Sub
没有调过,可能会有些错误,大致思路的话,就是上面这个样
热心网友 时间:2023-10-13 12:13
<books>
<book>
<title>C#和ASP.NET程序设计教程</title>
<author>木林森</author>
<price>38.00</price>
<pages>344</pages>
<press>清华大学出版社</press>
<publishdate>2002-1-1</publishdate>
</book>
<book>
...
</book>
...
</books>
热心网友 时间:2023-10-13 12:14
内容文档
命名为:XMLFile1.xml
<?xml
version="1.0"
encoding="utf-8"
?>
<books>
<book>
<title>C#和ASP.NET程序设计教程</title>
<author>木林森</author>
<price>38.00</price>
<pages>344</pages>
<press>清华大学出版社</press>
<publishdate>2002-1-1</publishdate>
</book>
<book>
…………
</book>
<books>
解释文档
命名为:XSLTFile1.xslt
<?xml
version="1.0"
encoding="UTF-8"
?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template
match="/">
<table
border="1">
<tr>
<td>书名</td>
<td>作者</td>
<td>价格</td>
<td>页数</td>
<td>出版社</td>
<td>出版日期</td>
<xsl:for-each
select="/books/book">
<tr>
<td><xsl:value-of
select="title"></xsl:value-of></td>
<td><xsl:value-of
select="author"></xsl:value-of></td>
<td><xsl:value-of
select="price"></xsl:value-of></td>
<td><xsl:value-of
select="pages"></xsl:value-of></td>
<td><xsl:value-of
select="press"></xsl:value-of></td>
<td><xsl:value-of
select="publishdate"></xsl:value-of></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
XML控件在.net中的引用
<asp:Xml
id="Xml1"
runat="server"></asp:xml>
调用过程(在vb.net中)
Private
Sub
Page_Load(ByVal
sender
As
System.Object,ByVal
e
As
System.EventArgs)
Handles
MyBase.Load
Xml1.DocumentSource
=
"XmlFile1.xml"
Xml1.TransformSource=
"XSLTFile1.xslt"
End
Sub
没有调过,可能会有些错误,大致思路的话,就是上面这个样