Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsXMLXMLHow to interpret not really typical XML file in XML moduleHow to interpret not really typical XML file in XML module
Previous
 
Next
New Post
7/20/2009 9:35 AM
 

Hello, I would really apreciate any help with following case. I have an XML file produced by one web service, this is an example:

<?xml version="1.0" encoding="utf-8"?>
<Result>
  <SCategory Id="0">
    <SCategory Code="" Name="" />
  </SCategory>
  <SCategory Id="2">
    <SCategory Code="AUDI" Name="AUDIO/VIDEO" />
  </SCategory>
</Result>

So within Result tag there are information about two SCategories with elements Id, Code and Name. I want to put all of these elements to table. I was trying to do that with following XSL file:

<?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>Kategorie:</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
      <th>Id</th>
      <th>Code</th>
      <th>Name</th>
      </tr>
      <xsl:for-each select="Result/SCategory">
      <tr>
        <td><xsl:value-of select="Id"/></td>
        <td><xsl:value-of select="Code"/></td>
        <td><xsl:value-of select="Name"/></td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

Only what I get is header of the table and two empty rows, so it looks like XML parser can find SCategory elements, but there's probably problem with interpreting of the rest of tags.

Does anybody idea what I am doing wrong? I was trying to change XSL file many times, but still without positive result....

Thanks a lot, Jan

 
New Post
7/20/2009 11:13 AM
 

Your XSL would work if the original XML source looked like this... which of course it does not.

<?xml version="1.0" encoding="utf-8"?>
<Result>
  <SCategory>
    <Id>0</Id>
    <Code></Code>
    <Name></Name>
  </SCategory>
  <SCategory>
    <Id>1</Id>
    <Code>AUDI</Code>
    <Name>AUDIO/VIDEO</Name>
  </SCategory>
</Result>


So, based on the XML you posted, try this...

<?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>Kategorie:</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
      <th>Id</th>
      <th>Code</th>
      <th>Name</th>
      </tr>
      <xsl:for-each select="Result/SCategory">
      <tr>
        <td><xsl:value-of select="@Id"/></td>
        <td><xsl:value-of select="SCategory/@Code"/></td>
        <td><xsl:value-of select="SCategory/@Name"/></td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsXMLXMLHow to interpret not really typical XML file in XML moduleHow to interpret not really typical XML file in XML module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out