Converting XML data into a HTML Table.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Converting XML data into a HTML Table.

  1. #1
    sharmila Guest

    Converting XML data into a HTML Table.


    If the Structure of my xml data is like this one below , how do i display
    it in HTML table.

    <books>
    <book>
    <title></title>
    <isbn></isbn>
    <authors>
    <author_name>....</author_name>
    <author_name>....</author_name>
    <author_name>....</author_name>
    </authors>
    <description></description>
    <price></price>
    <book>

    <book>
    <title></title>
    <isbn></isbn>
    <authors>
    <author_name>....</author_name>
    <author_name>....</author_name>
    <author_name>....</author_name>
    </authors>
    <description></description>
    <price></price>
    <book>
    </books>



  2. #2
    Jigesh Guest

    Re: Converting XML data into a HTML Table.


    Hi Sharmila,
    well you have to write one xsl file,
    which generates html table as output.

    In that table you have to split the cells of the column author as it again
    further shows author names,

    here is the sample xsl file which generates simple table,

    <?xml version="1.0" encoding="UTF-8"?>
    <HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <BODY>
    <table width="100%" border="1">
    <tr>
    <th bgcolor="#ABCDEF">
    EMPNO
    </th>
    <th bgcolor="#ABCDEF">
    ENAME
    </th>
    <th bgcolor="#ABCDEF">
    JOB
    </th>
    <th bgcolor="#ABCDEF">
    MGR
    </th>
    <th bgcolor="#ABCDEF">
    HIREDATE
    </th>

    <th bgcolor="#ABCDEF">
    SAL
    </th>

    <th bgcolor="#ABCDEF">
    COMM
    </th>
    <th bgcolor="#ABCDEF">
    DEPTNO
    </th>

    <th bgcolor="#ABCDEF">
    TEMP
    </th>

    </tr>
    <xsl:for-each select="ROWSET/ROW">
    <tr>
    <td>
    <xsl:value-of select="EMPNO"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="ENAME"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="JOB"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="MGR"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="HIREDATE"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="SAL"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="COMM"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="DEPTNO"></xsl:value-of>
    </td>
    <td>
    <xsl:value-of select="TEMP"></xsl:value-of>
    </td>
    </tr>
    </xsl:for-each>
    </table>

    </BODY>
    </HTML>


    Have a nice time,
    Jigesh.

    "sharmila" <sharmila_banu@hotmail.com> wrote:
    >
    >If the Structure of my xml data is like this one below , how do i display
    >it in HTML table.
    >
    ><books>
    > <book>
    > <title></title>
    > <isbn></isbn>
    > <authors>
    > <author_name>....</author_name>
    > <author_name>....</author_name>
    > <author_name>....</author_name>
    > </authors>
    > <description></description>
    > <price></price>
    > <book>
    >
    > <book>
    > <title></title>
    > <isbn></isbn>
    > <authors>
    > <author_name>....</author_name>
    > <author_name>....</author_name>
    > <author_name>....</author_name>
    > </authors>
    > <description></description>
    > <price></price>
    > <book>
    ></books>
    >
    >



  3. #3
    Hemen Guest

    Re: Converting XML data into a HTML Table.


    If you are not familiar with HTML, try using Front Page, Create a new page
    in Front Page, go to HTML tab, u'll see the necessary HTML, place this under
    <BODY> tag and put </BODY> at end, before </HTML>, although u can use any
    HTML editor, till you are more familiar with HTML.

    "sharmila" <sharmila_banu@hotmail.com> wrote:
    >
    >If the Structure of my xml data is like this one below , how do i display
    >it in HTML table.
    >
    ><books>
    > <book>
    > <title></title>
    > <isbn></isbn>
    > <authors>
    > <author_name>....</author_name>
    > <author_name>....</author_name>
    > <author_name>....</author_name>
    > </authors>
    > <description></description>
    > <price></price>
    > <book>
    >
    > <book>
    > <title></title>
    > <isbn></isbn>
    > <authors>
    > <author_name>....</author_name>
    > <author_name>....</author_name>
    > <author_name>....</author_name>
    > </authors>
    > <description></description>
    > <price></price>
    > <book>
    ></books>
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center