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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

databind xml to html table by column and not by row

Status
Not open for further replies.

1proguser

Programmer
Jan 4, 2005
1
US
Hi,

I have a xml file and need to bind the data to a html table. Binding each recordset in the xml file to each html table row is simple.

<XML ID = "xmlData" src = "myXMLFile.xml"></XML>

<TABLE BORDER = "1" DATASRC = "#xmlData" DATAPAGESIZE = "2"
ID = "tbl">
<THEAD>
<TR>
<TH>Last Name</TH>
</TR>
</THEAD>
<TR>
<TD><SPAN DATAFLD = "LastName"></SPAN></TD>
</TR>
</TABLE>

However, I would like to bind each xml recordset to each column (not bind by row) in the html table. Is this possible?

Thank you .
 
I don't think you can by default...

you might be able to get tricky with XSL and pull it off...

A very basic example would be...
Code:
[b]<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="/">[/b]
...
<TABLE BORDER = "1" ID = "tbl">
   <TR>
      <TD><b>LastName</b></TD>
      <TD>
        [b]<xsl:for-each select="//LastName">
          <xsl:value-of select="." />
        </xsl:for-each>[/b]
      </TD>
   </TR>
</TABLE>
...
[b]</xsl:template>
</xsl:stylesheet>[/b]

See an xsl example to see the rest

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top