Question

Using ASP.NET 2.0 i carried out below steps

book.xml

<?xml version="1.0"?>
<greeting>
  Hello, World!
</greeting>

data.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html"/>
  <xsl:template match="/">
    <xsl:apply-templates select="greeting"/>
  </xsl:template>
  <xsl:template match="greeting">
    <h1>
      <xsl:value-of select="."/>
    </h1>
  </xsl:template>
</xsl:stylesheet>

Page

<div>
   <asp:XmlDataSource runat="server" EnableCaching="false" ID="xmlDs" DataFile="~/book.xml" TransformFile="~/data.xsl"></asp:XmlDataSource>
</div>

Sadly nothing appears in the page, I expected a output Hello, World!. So what is wrong here?

Was it helpful?

Solution

I think the control you're looking for is <asp:Xml>:

<div>
    <asp:Xml id="test" DocumentSource="book.xml" TransformSource="data.xsl" runat="server"/>
</div>

XmlDataSource is generally used in combination with other data bound controls like TreeViews or Repeaters

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top