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!

Display Data on HTML browser

Status
Not open for further replies.

swaroop

Programmer
Feb 4, 2001
100
US
I have a data-file.xml it ahs 3 columns



column1 : Heading
Column2 : URL
Column3 : Disc

I am expecting to display this data as a table on browser as shown below

Column1 Column3
Test My Test Page

The data "My Test Page" has to be a hiperlink to and Yahoo.com is the second column in XML Page.

Thanks in advance.
 
XML files don't have columns, they have nodes. Whats the structure of the XML?

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
>> Whats the structure of the XML?

If you can post a portion on your XML, (you don't have to post the whole thing, just enough to see the pattern) we can help you with the XSL you need to convert it to a table...

basically,
if it has the structure:
Code:
<X>
 <Y>
  <Z1>col 1</Z1>
  <Z2>col 2</Z2>
  <Z3>col 3</Z3>
 </Y>
 <Y>
  <Z1>col 1</Z1>
  <Z2>col 2</Z2>
  <Z3>col 3</Z3>
 </Y>
</X>

the part of the XSL that would draw the table would look like:
Code:
...
<table>
  <tr>
    <th>[COLOR=blue]Col 1[/color]</th>
    <th>[COLOR=blue]Col 3[/color]</th>
  </tr>
  <xsl:for-each select="[COLOR=red]//Y[/color]">
     <tr>
       <xsl:value-of select="[COLOR=red]Z1[/color]" /></td>
       <xsl:value-of select="[COLOR=red]Z3[/color]" /></td>
     </tr>
  </xsl:for-each>
</table>
...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
CubeE101,

I wanted to display Z1(col 1) and Z3(col 3). The code is exactly similar as shown by you. Now Z2(col 2) is a url and when "col 3" displays I wanted to hyperlink to the URL in "col 2". Please advice.

Regards,

Swaroop.
 
Try this...
Code:
...
<table>
  <tr>
    <th>Col 1</th>
    <th>Col 3</th>
  </tr>
  <xsl:for-each select="//Y">
     <tr>
       <td><xsl:value-of select="Z1" /></td>
       <td>[b]<a href="{Z2}">[/b]<xsl:value-of select="Z3" />[b]</a>[/b]</td>
     </tr>
  </xsl:for-each>
</table>
...

(looks like I forgot the <td> start tags above... oops)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
I am getting an error

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Reference to undeclared namespace prefix: 'xsl'. Error processing resource 'file:///C:/Junk/Test.xsl'. Line 6, Position 30

<xsl:for-each select="//Y">


<!-- My XML File here (Test.xml) -->

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Test.xsl"?>
<X>
<Y>
<Z1>col 1</Z1>
<Z2> <Z3>News</Z3>
</Y>
<Y>
<Z1>col 1</Z1>
<Z2>mail.yahoo.com</Z2>
<Z3>MyMail</Z3>
</Y>
</X>

<!-- My XML File ends here -->

<!-- My XSL Starts here (Test.xsl) -->


<html>
<head>
<title>Swaroop
</title>
</head>
<body>
<table>
<tr>
<th>Col 1</th>
<th>Col 3</th>
</tr>
<xsl:for-each select="//Y">
<tr>
<td><xsl:value-of select="Z1" /></td>
<td><a href="{Z2}"><xsl:value-of select="Z3" /></a></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>



<!-- My XSL File ends here -->

Requested to Please suggest me how to handle this.

Thanks in advance.

Regards,
 
is that ALL of your XSL?

you need the stylesheet & template tags:

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]

<html>
<head>
<title>Swaroop
</title>
</head>
<body>
<table>
  <tr>
    <th>Col 1</th>
    <th>Col 3</th>
  </tr>
  <xsl:for-each select="//Y">
     <tr>
       <td><xsl:value-of select="Z1" /></td>
       <td><a href="{Z2}"><xsl:value-of select="Z3" /></a></td>
     </tr>
  </xsl:for-each>
</table>
</body>
</html>

[b]</xsl:template>
</xsl:stylesheet>[/b]



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