Please visit our sponsors !
Xml Control
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 |
Example 1
The following shows a sample XML file called "cdcatalog.xml":
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>
|
The following shows a sample XSLT file called "cdcatalog.xsl":
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>
|
The following example shows how to use the Xml control to display the sample
XML file using the sample XSLT file:
<html>
<body>
<form runat="server">
<asp:Xml id="cd" DocumentSource="cdcatalog.xml"
TransformSource="cdcatalog.xsl" runat="server"/>
</form>
</body>
</html>
|
Jump to: Top of Page
or HOME or
Printer friendly page
Search W3Schools:
What Others Say About Us
Does the world know about us? Check out these places:
Dogpile
Alta Vista
MSN
Google
Excite
Lycos
Yahoo
Ask Jeeves
We Help You For Free. You Can Help Us!
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2002 by Refsnes Data. All Rights Reserved
|