Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
I totally second John.
XSL have been designed with problem like yours in mind.
I have added a reference to a XSL style sheet to your xml example
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="tbl.xsl" type="text/xsl"?>
<rows>
<!-- Begin Row -->
<row id="1">
<!-- Property Name --><cell>2500-2530 West Third Street</cell>
<!-- St. --><cell></cell>
<!-- Address --><cell>2500-2530 West Third Street</cell>
<!-- City --><cell>Cleveland</cell>
<!-- ST --><cell>OH</cell>
<!-- Zip --><cell>44113</cell>
<!-- WH --><cell>1</cell>
<!-- Office SF --><cell>1</cell>
<!-- Docks --><cell></cell>
<!-- Drive-ins --><cell></cell>
<!-- Clear --><cell></cell>
<!-- Crane Rail--><cell></cell>
<!-- Div-isible SF --><cell></cell>
<!-- Lease Rate/ SF --><cell></cell>
<!-- Comments --><cell></cell>
</row>
</rows>
Save this file as a file named data.xml
Now, save this into tbl.xsl into the same directory as data.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="html" encoding="UTF-8" indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
standalone="yes" omit-xml-declaration="yes"
/>
<xsl:template match="/">
<html>
<head>
<title>xml to table</title>
</head>
<body>
<table width="100%" border="1">
<xsl:for-each select="/rows/row">
<tr>
<xsl:for-each select="cell">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
and with a firefox or IE browser open, drop the xml file on it.
Any modern browser can transform this internally.
It will read the XML datas, fetch the XSL style sheet and generate an HTML output from the stylesheet.
__________________
Only a biker knows why a dog sticks his head out the window.
|