Hi everyone!
So I have a XML code

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="pizza.xsl"?>
<pizza_list>
	<food>
		<name>Margarita</name>
		<description>tomato sauce</description>
		<price>3.60 </price>
		<diameter>30 cm</diameter>
	</food>
	<food>
		<name>Green</name>
		<description>tomato, oregano</description>
		<price>5.40 </price>
		<diameter>30 cm</diameter>
	</food>
	<food>
		<name>Primaverra</name>
		<description>tomato, mozzarella, cucumber</description>
		<price>5.30 </price>
		<diameter>30 cm</diameter>
	</food>
	<food>
		<name>Sandokan</name>
		<description>tomato, crab meat</description>
		<price>6.40 </price>
		<diameter>30 cm</diameter>
	</food>
	<food>
		<name>Caribia</name>
		<description>tomato, garlic, lemon, shrimp</description>
		<price>6.60 </price>
		<diameter>30 cm</diameter>
	</food>
</pizza_list>

So how to put this into HTML table?
I've tried this:

<HTML>
      <HEAD>
<Title>Pizza Menu:</Title>
      </HEAD>
       <BODY>
       <xml id="pizza" src="pizza.xml"></xml>  
       <table DATASRC="pizza.xml" Border=4>
          <thead>
	<th>Pizza:</th>
	<th>Description:</th>
	<th>Price:</th>
	<th>Diameter:</th>	    
           </thead>
	<tbody>
	<xsl:for-each select="pizza/food">
	<tr>
	<td><span DATAFLD="name"></span></td>
	<td><span DATAFLD="description"></span></td>
	<td><span DATAFLD="price"></span></td>
	<td><span DATAFLD="diameter"></span></td>
	</tr>
	</xsl:for-each>
	</tbody>
       </table>
      </BODY>
</HTML>

I've tried but the pizzas aren't showing in the table!
Help!

I've done it with java script.

e

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table border="4">
<thead>
<th>Pizza:</th>
<th>Description:</th>
<th>Price:</th>
<th>Diameter:</th>
</thead>
<tbody>
<xsl:for-each select="pizza_list/food">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="description"/></td>
<td><xsl:value-of select="price"/></td>
<td><xsl:value-of select="diameter"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
</xsl:stylesheet>-------raghavendra delhi(9015367023)

e

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table border="4">
<thead>
<th>Pizza:</th>
<th>Description:</th>
<th>Price:</th>
<th>Diameter:</th>
</thead>
<tbody>
<xsl:for-each select="pizza_list/food">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="description"/></td>
<td><xsl:value-of select="price"/></td>
<td><xsl:value-of select="diameter"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
</xsl:stylesheet>

yeah...I've tried it that way too... doesn't work. It shows the table but there's no data from the xml in it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.