transformation on XML in basic repeater

D Collins asked on February 28, 2014 10:34

I'm trying to find examples of how to display data from an XML document. I've read the documentation on it, but ti seems to involve a fair bit of back-end ASP coding, which doesn't seem very 'basic' at all.

Here a sample of my XML doc:
<?xml version="1.0" encoding="UTF-8"?>
<employees>
    <employee id="1">
        <name id="dcollins">
            <first>Dave</first>
            <last>Collins</last>
        </name>
    </employee>
</employees>

What I'm trying to display is

<img src="dcollins.jpg" /><br/>
<span>Dave Collins</span>

But so far, I haven't found examples of how to actually get the data. I've tried things like this, which of course don't work:

<%#Eval("employees")%>,
<%#Eval("employees.employee.name.first")%>,
<%#DataBinder.Eval(Container.DataItem, "employees")%>

Recent Answers


D Collins answered on February 28, 2014 10:44 (last edited on February 28, 2014 10:44)

While I'm at it, something else I don't understand. The Transformation Dialogue wants me to specify a Document Type, i.e. it requires me to put my Transform under a certain type of Document. I have no idea what to pick, since this is not associated with a document, nor are there any existing types in the list that are suitable. I just picked 'CMS.Article' randomly.

0 votesVote for this answer Mark as a Correct answer

D Collins answered on February 28, 2014 11:16

I'm trying XSLT Transformations now. And i'v edramitcally simplified the XML unti .I get something working.

XML:

<?xml version="1.0" encoding="UTF-8"?>
<employees>
    <employee id="1">Dave Collins</employee>
    <employee id="2">Siby Jacob</employee>
</employees>

Transform (which does not work):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />

  <xsl:template match="cms.article">
    <p>    <xsl:apply-templates select="employees"/>    </p>
  </xsl:template>

  <xsl:template match="employees">
    <span><xsl:apply-templates select="employee"/></span>
  </xsl:template>  

  <xsl:template match="employee">
    <span><xsl:value-of select="."/></span>
  </xsl:template>  

</xsl:stylesheet> 

There's something about the root - "cms.article" versus "/" that I don't get.

0 votesVote for this answer Mark as a Correct answer

Jagdish Narkar answered on June 13, 2014 01:58

Try replacing

<xsl:template match="cms.article"> with

<xsl:template match="/">

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.