|
|||||||
| XML Discussion and technical support for using and deploying XML applications and websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I need some help getting the data from the xml into html table.
this is a sample of the XML: Code:
<UniFact> <Producten> <Product Type="EEK 260 VA" Merk="Etna" ProductgroepNummer="4.13.5" Hoofdgroep="Witgoed" HoofdgroepID="ab4a9d79-5176-4662-8476-0d76a0a2c2c9" Subgroep="Inbouw koelkast" SubgroepID="de969381-d040-493a-bf14-6d3b220a0499" Subsubgroep="170 cm en hoger" SubsubgroepID="bda7e292-de68-42f0-810e-6ee5b763a5b0" Goingprijs="999.00" Brutoprijs="999.00" Verkoopprijs="487.00" Nettoprijs="270.84" Leverancier="Atag Etna Pelgrim HomeProducts B.V." EAN="" Verwijderingsbijdrage="14.29"> <Kenmerk Naam="Energieklasse" Eenheid="">A</Kenmerk> <Kenmerk Naam="Netto Inhoud koelgedeelte" Eenheid="liter">176</Kenmerk> <Kenmerk Naam="Nismaat Hoogte" Eenheid="cm">177.5</Kenmerk> <Kenmerk Naam="Nismaat Breedte" Eenheid="cm">57</Kenmerk> <Kenmerk Naam="Nismaat Diepte" Eenheid="cm">56</Kenmerk> </Product> Code:
------------------------------------------------------------------- | Type | Merk | Hoofdgroep | Energieklasse | Nismaat Hoogte | ------------------------------------------------------------------- | EEK 260 VA | Etna | Witgoed | A | 177.5 cm | ------------------------------------------------------------------- A 176 177.5 57 56 I've used <xsl:value-of select="producten"/> Can anyone help me? Last edited by Etimm; 04-12-2006 at 03:30 PM. |
|
#2
|
||||
|
||||
|
Here's what I came up with:
test.xsl: 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="xml"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />
<title>Page Title</title>
<style type="text/css">
table {
border-collapse: collapse;
border: solid 1px black;
}
th, td {
border: solid 1px black;
padding: 0.2em 0.5em;
}
</style>
</head>
<body>
<table>
<tr>
<th>Type</th>
<th>Merk</th>
<th>Hoofdgroep</th>
<th>Energieklasse</th>
<th>Nismaat Hoogte</th>
</tr>
<xsl:for-each select="Unifact/Producten/Product">
<tr>
<td><xsl:value-of select="@Type"/></td>
<td><xsl:value-of select="@Merk"/></td>
<td><xsl:value-of select="@Hoofdgroep"/></td>
<td><xsl:value-of select="Kenmerk[@Naam='Energieklasse']"/></td>
<td>
<xsl:value-of select="Kenmerk[@Naam='Nismaat Hoogte']"/>
<xsl:value-of select="Kenmerk[@Naam='Nismaat Hoogte']/@Eenheid"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<Unifact>
<Producten>
<Product Type="EEK 260 VA" Merk="Etna" ProductgroepNummer="4.13.5" Hoofdgroep="Witgoed" HoofdgroepID="ab4a9d79-5176-4662-8476-0d76a0a2c2c9" Subgroep="Inbouw koelkast" SubgroepID="de969381-d040-493a-bf14-6d3b220a0499" Subsubgroep="170 cm en hoger" SubsubgroepID="bda7e292-de68-42f0-810e-6ee5b763a5b0" Goingprijs="999.00" Brutoprijs="999.00" Verkoopprijs="487.00" Nettoprijs="270.84" Leverancier="Atag Etna Pelgrim HomeProducts B.V." EAN="" Verwijderingsbijdrage="14.29">
<Kenmerk Naam="Energieklasse" Eenheid="">A</Kenmerk>
<Kenmerk Naam="Netto Inhoud koelgedeelte" Eenheid="liter">176</Kenmerk>
<Kenmerk Naam="Nismaat Hoogte" Eenheid="cm">177.5</Kenmerk>
<Kenmerk Naam="Nismaat Breedte" Eenheid="cm">57</Kenmerk>
<Kenmerk Naam="Nismaat Diepte" Eenheid="cm">56</Kenmerk>
</Product>
<Product Type="EEK 260 VA" Merk="Etna" ProductgroepNummer="4.13.5" Hoofdgroep="Witgoed" HoofdgroepID="ab4a9d79-5176-4662-8476-0d76a0a2c2c9" Subgroep="Inbouw koelkast" SubgroepID="de969381-d040-493a-bf14-6d3b220a0499" Subsubgroep="170 cm en hoger" SubsubgroepID="bda7e292-de68-42f0-810e-6ee5b763a5b0" Goingprijs="999.00" Brutoprijs="999.00" Verkoopprijs="487.00" Nettoprijs="270.84" Leverancier="Atag Etna Pelgrim HomeProducts B.V." EAN="" Verwijderingsbijdrage="14.29">
<Kenmerk Naam="Energieklasse" Eenheid="">A</Kenmerk>
<Kenmerk Naam="Netto Inhoud koelgedeelte" Eenheid="liter">176</Kenmerk>
<Kenmerk Naam="Nismaat Hoogte" Eenheid="cm">177.5</Kenmerk>
<Kenmerk Naam="Nismaat Breedte" Eenheid="cm">57</Kenmerk>
<Kenmerk Naam="Nismaat Diepte" Eenheid="cm">56</Kenmerk>
</Product>
</Producten>
</Unifact>
__________________
"That's what the gods are! An answer that will do! Because there's food to be caught and babies to be born and life to be lived and so there is not time for big, complicated, and worrying answers! Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." -- from Nation, by Terry Pratchett freelancer.internet.com Email me |
|
#3
|
|||
|
|||
|
Thank you! This is perfect!
However the XML I must work with is far from perfect Somehow I'll have to correct the XML file (wich contain 20.000 products) |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|