Web Server Controls->ASP.NET XML Control
2007-03-28 08:08
579 查看
Definition and Usage
The XML control is used to display an XML document or the results of an XSL Transform.Note: At least one of the XML Document properties must be set or no XML document is displayed.
You can also specify an XSLT document that will format the XML document before it is written to the output. You can format the XML document with the Transform property or the TransformSource property.
Properties
Property | Description |
---|---|
Document | Specifies an XML document using a System.Xml.XmlDocument object |
DocumentContent | Specifies an XML string |
DocumentSource | Specifies a path to an XML file to display |
id | A unique id for the control |
runat | Specifies that the control is a server control. Must be set to "server" |
Transform | Formats the XML document using a System.Xml.Xsl.XslTransform object |
TransformSource | Specifies a path to an XSL Transform file |
Examples
XMLASPX Source:
<html> <body> <form runat="server"> <asp:Xml DocumentSource="cdcatalog.xml" TransformSource="cdcatalog.xsl" runat="server" /> </form> <p><a href="cdcatalog.xml" target="_blank">View XML file</a></p> <p><a href="cdcatalog.xsl" target="_blank">View XSL file</a></p> </body> </html> |
My CD Collection
View XSL file |
If you click the link "View XML file",it will show:
<?xml version="1.0" encoding="ISO-8859-1" ?> - <!-- Edited with XML Spy v2007 (http://www.altova.com) --> f(clean); - <catalog> - <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> - <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <country>UK</country> <company>CBS Records</company> <price>9.90</price> <year>1988</year> </cd> - <cd> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <country>USA</country> <company>RCA</company> <price>9.90</price> <year>1982</year> </cd> - <cd> <title>Still got the blues</title> <artist>Gary Moore</artist> <country>UK</country> <company>Virgin records</company> <price>10.20</price> <year>1990</year> </cd> - <cd> <title>Eros</title> <artist>Eros Ramazzotti</artist> <country>EU</country> <company>BMG</company> <price>9.90</price> <year>1997</year> </cd> </catalog> |
<?xml version="1.0" encoding="ISO-8859-1" ?> - <!-- Edited with XML Spy v2007 (http://www.altova.com) --> f(clean); - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:template match="/"> - <html> - <body> <h2>My CD Collection</h2> - <table border="1"> - <tr bgcolor="#9acd32"> <th align="left">Title</th> <th align="left">Artist</th> </tr> - <xsl:for-each select="catalog/cd"> - <tr> - <td> <xsl:value-of select="title" /> </td> - <td> <xsl:value-of select="artist" /> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> |
相关文章推荐
- Web Server Controls->ASP.NET CheckBox Control
- Web Server Controls->ASP.NET Label Control
- Web Server Controls->ASP.NET RadioButton Control
- Web server Controls->ASP.NET TextBox Control
- Web Server Controls->ASP.NET LinkButton Control
- Web Server Controls->ASP.NET RadioButtonList Control
- Web Server Controls->ASP.NET ListBox Control
- Web Server Controls->ASP.NET AdRotator Control
- Web Server Controls->ASP.NET DropDownList Control
- Web Server Controls->ASP.NET Literal Control
- Web Server Controls->ASP.NET HyperLink Control
- Web Server Controls->ASP.NET Button Control
- Web Server Controls->ASP.NET Panel Control
- Web Server Controls->ASP.NET Table Control
- Web Server Controls->ASP.NET TableCell Control
- Web Server Controls->ASP.NET Image Control
- Web Server Controls->ASP.NET PlaceHolder Control
- Web Server Controls->ASP.NET TableRow Control
- Web Server Controls->ASP.NET ImageButton Control
- ASP.NET AJAX Roadmap--Server Controls (13): ScriptManager Control Overview