Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Databinding Returning nothing

Status
Not open for further replies.

Kavius

Programmer
Apr 11, 2002
322
CA
I am having trouble binding my xml to an html document. When I bind the data, nothing shows in the body of the table.

The code:
Code:
<HTML>
<HEAD>
<xml id=&quot;BookList&quot;>
  <book>
    <bookid>1</bookid>
    <title>Of the Causes of Wonderful Things</title>
    <subtitle></subtitle>
    <author>
      <fname>John</fname>
      <mname>Baptist</mname>
      <lname>Porta</lname>
    </author>
  </book>
  <book>
    <bookid>2</bookid>
    <title>Of the Generation of Animals</title>
    <subtitle></subtitle>
    <author>
      <fname>John</fname>
      <mname>Baptist</mname>
      <lname>Porta</lname>
    </author>
  </book>
</xml>

</HEAD>
<BODY>
  <table border=&quot;0&quot; datasrc=&quot;#BookList&quot;>

    <thead>
      <tr>
        <th>ISBN</th>
        <th>Title</th>
        <th>SubTitle</th>
      </tr>
    </thead>

    <tfoot>
      <tr>
        <th>((</th>
        <th>))</th>
      </tr>
    </tfoot>

    <tbody>
      <tr>
        <td><span datafld=&quot;bookid&quot;></span></td>
        <td><span datafld=&quot;title&quot;></span></td>
        <td><span datafld=&quot;subtitle&quot;></span></td>
      </tr>
    </tbody>

  </table>

</BODY>

</HTML>
 
Unfortunately, I thought it might be something syntactical (is that even a word?), so I went to W3Schools and got their code for doing just such a thing. I figure if I can get a sample working, I can always modify the variables to point to my data. I cut and paste the code off of their page, made the modifications to account for a change in host, and got the exact same results I was getting before.

w3schools example:

My page:
 
OK, so I figured it out...

Look at the XML and count the top level elements. I'm pretty new to XML but I know that I read that you are allowed only 1 top level element. The booklist has 2 books. I have corrected this by encapsulating the two books in a <booklist> tag. This has fixed the error.

The above URL will likely not work for a while, but with this working I will likely have it up as booklist.asp in the near future.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top