XML Viewer WebPart可以将数据源为xml的内容显示到页面中,本文简单说明
1.新建一个页面用于测试使用,在Site Action下的New Page:
2.在Insert tab插入WebPart,选择Content Rollup类别下的XML Viewer:
3.XML Viewer添加到页面后点击open the tool pane:
4.在属性面板中将我们准备好的XML和XSL文件内容输入进去:
Xml文件内容如下:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="Employees.xsl"?>
<Employees>
<Employee>
<EmployeeID>1</EmployeeID>
<EmployeeDes type="choice">Cary,your post?</EmployeeDes>
<posts>
<post>SSE</post>
<post>SA</post>
<post>PM</post>
</posts>
</Employee>
<Employee>
<EmployeeID>2</EmployeeID>
<EmployeeDes type="choice">James,your post?</EmployeeDes>
<posts>
<post>SSE</post>
<post>SA</post>
<post>PM</post>
</posts>
</Employee>
</Employees>
Xsl文件内容如下:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1>Employee Post Form</h1>
<ol>
<xsl:for-each select="//Employee">
<li>
<strong>
<xsl:value-of select="EmployeeDes"/>
</strong>
<br/>
<xsl:for-each select="posts/post">
<span style="font-style: italic;">
<input type="radio">
<xsl:attribute name="name">
<xsl:value-of select="http://www.cnblogs.com/EmployeeID"/>
</xsl:attribute>
<xsl:value-of select="."/>
</input>
</span>
<br/>
</xsl:for-each>
</li>
<br/>
</xsl:for-each>
</ol>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
5.确定后显示如下:
本文转自Justin博客园博客,原文链接:http://www.cnblogs.com/carysun/archive/2010/12/31/moss2010-xmlwp.html,如需转载请自行联系原作者