DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Transform XML into HTML table

  1. #1
    Darryl McCool Guest

    Transform XML into HTML table



    Here is my XML:

    <ITEMS>
    <TABLE>
    <ITEM>Mouse</ITEM>
    <ITEM>Keyboard</ITEM>
    <ITEM>Monitor</ITEM>
    <ITEM>CPU</ITEM>
    </TABLE>
    <TABLE>
    <ITEM>Windows 2000</ITEM>
    <ITEM>J2EE</ITEM>
    <ITEM>Office 2000</ITEM>
    </TABLE>
    </ITEMS>

    I need the following HTML (A table with x rows and 2 columns)

    <HTML>
    <BODY>
    <TABLE>
    <TR>
    <TD>Mouse</TD>
    <TD>Keyboard</TD>
    </TR>
    <TR>
    <TD>Monitor</TD>
    <TD>CPU</TD>
    </TR>
    </TABLE>
    <TABLE>
    <TR>
    <TD>Windows 2000</TD>
    <TD>J2EE</TD>
    </TR>
    <TD>Office 2000</TD>
    <TR>
    </TABLE>
    </BODY>
    </HTML>

    The problem that I am having is writing a style sheet that puts the <TR>
    </TR> tags around two items at a time. If anyone can supply the XSLT code
    to do this, it would be greatly appreciated.

    Darryl


  2. #2
    Michael Shutt Guest

    Re: Transform XML into HTML table

    If you are not adverse to using script, you could use the index() property
    to achieve this. There is an example in the XSL Developers Guide. Search
    for "Placing a List of Items into a Grid with the context() Method".

    "Darryl McCool" <darryl.mcool@nurun.com> wrote in message
    news:3a82cf18$1@news.devx.com...
    >
    >
    > Here is my XML:
    >
    > <ITEMS>
    > <TABLE>
    > <ITEM>Mouse</ITEM>
    > <ITEM>Keyboard</ITEM>
    > <ITEM>Monitor</ITEM>
    > <ITEM>CPU</ITEM>
    > </TABLE>
    > <TABLE>
    > <ITEM>Windows 2000</ITEM>
    > <ITEM>J2EE</ITEM>
    > <ITEM>Office 2000</ITEM>
    > </TABLE>
    > </ITEMS>
    >
    > I need the following HTML (A table with x rows and 2 columns)
    >
    > <HTML>
    > <BODY>
    > <TABLE>
    > <TR>
    > <TD>Mouse</TD>
    > <TD>Keyboard</TD>
    > </TR>
    > <TR>
    > <TD>Monitor</TD>
    > <TD>CPU</TD>
    > </TR>
    > </TABLE>
    > <TABLE>
    > <TR>
    > <TD>Windows 2000</TD>
    > <TD>J2EE</TD>
    > </TR>
    > <TD>Office 2000</TD>
    > <TR>
    > </TABLE>
    > </BODY>
    > </HTML>
    >
    > The problem that I am having is writing a style sheet that puts the <TR>
    > </TR> tags around two items at a time. If anyone can supply the XSLT code
    > to do this, it would be greatly appreciated.
    >
    > Darryl
    >




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