Problem with binding xml data with html document

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Azhar16
    New Member
    • May 2007
    • 1

    Problem with binding xml data with html document

    Hi I am having a really hard time binding this xml file with my html file.
    [code=xml]<?xml version="1.0" encoding="ISO-8859-1" ?>

    <?xml-stylesheet type="text/css" href="library.c ss"?>

    <LIBRARY>
    <BOOK>
    <TITLE>Harry Potter and the Deathly Hallows</TITLE>
    <AUTHOR>J.K. Rowling</AUTHOR>
    <GENRE>Fantas y</GENRE>
    <PRICE>17.99</PRICE>
    <PUBLISH>Arth ur A. Levine Books</PUBLISH>

    </BOOK>
    <BOOK>
    <TITLE>A Thousand Splendid Suns</TITLE>
    <AUTHOR>Khale d Hosseini</AUTHOR>
    <GENRE>Fictio n</GENRE>
    <PRICE>14.27</PRICE>
    <PUBLISH>Riverh ead Hardcover</PUBLISH>
    </BOOK>
    <BOOK>
    <TITLE>The Assault on Reason</TITLE>
    <AUTHOR>Al Gore</AUTHOR>
    <GENRE>Factua l</GENRE>
    <PRICE>15.57</PRICE>
    <PUBLISH>Pengui n Press HC</PUBLISH>
    </BOOK>
    <BOOK>
    <TITLE>Requie m For An Assassin</TITLE>
    <AUTHOR>Barry Eisler</AUTHOR>
    <GENRE>Thriller </GENRE>
    <PRICE>14.97</PRICE>
    <PUBLISH>Putn am Adult</PUBLISH>
    </BOOK>
    <BOOK>
    <TITLE>The Overlook</TITLE>
    <AUTHOR>Micha el Connelly</AUTHOR>
    <GENRE>Myster y</GENRE>
    <PRICE>13.19</PRICE>
    <PUBLISH>Little , Brown and Company</PUBLISH>
    </BOOK>
    <PERIODICAL>
    <TITLE>Sports Illustrated for Kids</TITLE>
    <PUBLISHER>Th e Time Inc. Magazine Company</PUBLISHER>
    <PRICE>19.95</PRICE>
    <FORMAT>Magazin e</FORMAT>
    </PERIODICAL>
    <PERIODICAL>
    <TITLE>Discouve r</TITLE>
    <PUBLISHER>Disc ouver Media LLC</PUBLISHER>
    <PRICE>19.95</PRICE>
    <FORMAT>Magazin e</FORMAT>
    </PERIODICAL>
    <PERIODICAL>
    <TITLE>Men's Health</TITLE>
    <PUBLISHER>Roda le Inc</PUBLISHER>
    <PRICE>24.94</PRICE>
    <FORMAT>Magazin e</FORMAT>
    </PERIODICAL>
    <CD>
    <TITLE>Never</TITLE>
    <AUTHOR>Paul Oakenfold</AUTHOR>
    <COMPANY>Maveri ck</COMPANY>
    <PRICE>6.99</PRICE>
    <YEAR>2006</YEAR>
    <FORMAT>CD Single</FORMAT>
    </CD>
    <CD>
    <TITLE>1 in 21: Tupac Shakur Story</TITLE>
    <AUTHOR>Tupac Shakur</AUTHOR>
    <COMPANY>AIM</COMPANY>
    <PRICE>18.99</PRICE>
    <YEAR>2001</YEAR>
    <FORMAT>CD</FORMAT>
    </CD>
    <CD>
    <TITLE>CLUB</TITLE>
    <AUTHOR>Paul Oakenfold</AUTHOR>
    <COMPANY>Perfec to</COMPANY>
    <PRICE>19.99</PRICE>
    <YEAR>2005</YEAR>
    <FORMAT>CD</FORMAT>
    </CD>
    <MOVIE>
    <TITLE>The 40 Year Old Virgin: Unrated</TITLE>
    <STUDIO>Univers al Home Entertainment</STUDIO>
    <RATING>Rated R</RATING>
    <GENRE>Comedy </GENRE>
    <PRICE>18.99</PRICE>
    <YEAR>2007</YEAR>
    <FORMAT>DVD</FORMAT>
    </MOVIE>
    <MOVIE>
    <TITLE>Lord of the Rings: Trilogy</TITLE>
    <STUDIO>Allianc e</STUDIO>
    <RATING>Rated 14A</RATING>
    <GENRE>Fantas y</GENRE>
    <PRICE>59.99</PRICE>
    <YEAR>2006</YEAR>
    <FORMAT>DVD</FORMAT>
    </MOVIE>
    <MOVIE>
    <TITLE>Pirate s of the Caribbean:Dead Man's Chest</TITLE>
    <STUDIO>Disne y</STUDIO>
    <RATING>PG 13</RATING>
    <GENRE>Adventur e</GENRE>
    <PRICE>26.99</PRICE>
    <YEAR>2006</YEAR>
    <FORMAT>DVD</FORMAT>
    </MOVIE>
    <MOVIE>
    <TITLE>Blood In Blood Out</TITLE>
    <STUDIO>Disne y</STUDIO>
    <RATING>Rated R</RATING>
    <GENRE>Drama</GENRE>
    <PRICE>21.99</PRICE>
    <YEAR>2000</YEAR>
    <FORMAT>DVD</FORMAT>
    </MOVIE>
    </LIBRARY>[/code]

    Basically what im trying to do is to separate Book, Periodicals, CDs, and Movies into separate tables. This is the code I currently have for my html file:


    [code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <xml id="LIBRARY" src="library.xm l"></xml>
    <title>Person al Library</title>
    </head>
    <body text="black">
    <h1>Welcome to my Personal Library</h1>

    <h2>Books
    <table border = "1" width="100%" summary="Book Details" datasrc="#LIBRA RY">
    <thead style="backgrou nd-color: #CAFF70;">
    <tr>
    <th>Title</th><th>Author</th><th>Genre</th><th>Publishe r</th><th>$ Price $</th>
    </tr>
    </thead>

    <tbody>
    <tr>
    <td align="left" >
    <SPAN DATAFLD="TITLE" >
    </SPAN>
    </td>
    <td align="center"> <div datafld="AUTHOR " /></td>
    <td align="center"> <div datafld="GENRE" /></td>
    <td align="center"> <div datafld="PUBLIS H" /></td>
    <td align="right">< div datafld="PRICE" /></td>
    </tr>
    </tbody>
    </table>

    <h2>Periodica ls
    <table border = "1" width="100%" summary="Period ical Details Details" datasrc="#LIBRA RY">
    <thead style="backgrou nd-color: #98FB98;">
    <tr>
    <th>Title</th><th>Publishe r</th><th>Format</th><th>$ Price $</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td align="left" ><div datafld="TITLE" /></td>
    <td align="center"> <div datafld="PUBLIS HER" /></td>
    <td align="center"> <div datafld="FORMAT " /></td>
    <td align="right">< div datafld="PRICE" /></td>
    </tr>
    </tbody>
    </table>

    <h2>CD
    <table border = "1" width="100%" summary="CD Details" datasrc="#LIBRA RY">
    <thead style="backgrou nd-color: #BBFFFF;">
    <tr>
    <th>Title</th><th>Author</th><th>Company</th><th>Year</th><th>Format</th><th>$ Price $</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td align="left" ><div datafld="TITLE" /></td>
    <td align="center"> <div datafld="AUTHOR " /></td>
    <td align="center"> <div datafld="COMPAN Y" /></td>
    <td align="center"> <div datafld="YEAR" /></td>
    <td align="center"> <div datafld="FORMAT " /></td>
    <td align="right">< div datafld="PRICE" /></td>
    </tr>
    </tbody>
    </table>

    <h2>Movie
    <table border = "1" width="100%" summary="Movie Details" datasrc="#LIBRA RY">
    <thead style="backgrou nd-color: #C6E2FF;">
    <tr>
    <th>Title</th><th>Studio</th><th>Rating</th><th>Genre</th><th>Year</th><th>Format</th><th>$ Price $</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td align="left" ><div datafld="TITLE" /></td>
    <td align="center"> <div datafld="STUDIO " /></td>
    <td align="center"> <div datafld="RATING " /></td>
    <td align="center"> <div datafld="GENRE" /></td>
    <td align="center"> <div datafld="YEAR" /></td>
    <td align="center"> <div datafld="FORMAT " /></td>
    <td align="right">< div datafld="PRICE" /></td>
    </tr>
    </tbody>
    </table>
    </body>
    </html>[/code]

    Thank you for your time, :-)
    I would really appreciate your help
  • dorinbogdan
    Recognized Expert Contributor
    • Feb 2007
    • 839

    #2
    Welcome to TheScripts TSDN...

    I'm not sure what is the binding problem.
    I could not test the code yet, but please give some details about expected result.

    Thanks,
    Dorin.

    Comment

    • dorinbogdan
      Recognized Expert Contributor
      • Feb 2007
      • 839

      #3
      It seems that you need to use XSL.
      Please take a look at this short tutorial, and try to play with XSL.
      You will need to output as HTML.
      We cannot write code for you (because of site rules), but we'll try to offer suggestions and small snippets.

      Dorin.

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        Your doctype for the html is incomplete. See the article about doctypes in html/css. In this case, you probably want to use XHTML.

        Also, you are using XML attributes in the HTML document that don't exist there.

        XML should be written in lower case, too.

        Comment

        Working...