Need Help with XML

Last post 07-04-2008 4:42 AM by Samu Zhang - MSFT. 4 replies.

Sort Posts:

  • Need Help with XML

    06-30-2008, 11:54 AM

    I am attempting to import XML data into a grid view. The XML data is weather observation data from the National Weather Service. I placed a XMLDataSource control onto the page and entered the following data:

    Data File: http://www.weather.gov/data/current_obs/KLIT.xml

    Transform File: ~/App_Data/klit.xsl

    Here is my transform file (developed using the W3Schools Tutorial): <?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>Little Rock, Adams Field</h2>

    <table border="1">

    <tr bgcolor="#9acd32">

    <th>Weather</th>

    <th>Temperature (F)</th>

    </tr>

    <tr>

    <td>

    <xsl:value-of select="weather"/>

    </td>

    <td>

    <xsl:value-of select="temp_f"/>

    </td>

    </tr>

    </table>

    </body>

    </html> </xsl:template>

    </xsl:stylesheet>

    I usually get an error that says "

    The data source for GridView with id 'LittleRock' did not have any properties or attributes from which to generate columns.  Ensure that your data source has content."

    Any help would be much appreciated. I am a beginner so bear with me! Big Smile

  • Re: Need Help with XML

    06-30-2008, 12:24 PM
    • Loading...
    • Ganeshyb
    • Joined on 11-02-2007, 4:07 AM
    • Posts 201

    There is no need for XSL in your case unless you want to tranform it into xml rather than HTML. What Gridview reqires is a binding that supports IEnumerable interface or a DataTable or a DataSet.

    In your case the xml is being tranformed into HTML and then binded which the GridView couldnt recognize. remove the XSL transformation and try.

    Thanks
    Ganesh


    If you find my reply help you Mark it Answered.
  • Re: Need Help with XML

    06-30-2008, 12:52 PM
    What exactly is IE numerable interface?
  • Re: Need Help with XML

    06-30-2008, 1:21 PM
    • Loading...
    • Ganeshyb
    • Joined on 11-02-2007, 4:07 AM
    • Posts 201
    Thanks
    Ganesh


    If you find my reply help you Mark it Answered.
  • Re: Need Help with XML

    07-04-2008, 4:42 AM
    Answer

    Hi weatherguy08 ,

    I tested your xlst with the link you provided. The result is :

     

    <html>
      <body>
        <h2>Little Rock, Adams Field</h2>
        <table border="1">
          <tr bgcolor="#9acd32">
            <th>Weather</th>
            <th>Temperature (F)</th>
          </tr>
          <tr>
            <td>
            </td>
            <td>
            </td>
          </tr>
        </table>
      </body>
    </html>

    So this xml file can not be understand by GridView control. See this link to learn how to bind xml to GridView.


    bind xml to gridview using xslt
    http://forums.asp.net/t/1216730.aspx

     

     

    Sincerely,
    Samu Zhang
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
Page 1 of 1 (5 items)
Microsoft Communities
Page view counter