Match any node in XML document using XSLT even if I don't know the names of the nodes

graninenrei

New Member
How do I transform a XML doc using XSTL when I don't know the names of the nodes. So basically it should work universally, with any XML document. Let's say I got this XML document:\[code\]<?xml version="1.0"?><?xml-stylesheet href="http://stackoverflow.com/questions/13841561/transform.xsl" type="text/xsl" ?><!DOCTYPE cinema [<!ELEMENT a (b*)><!ELEMENT b (c,d,e)><!ELEMENT c (#PCDATA)><!ELEMENT d (#PCDATA)><!ELEMENT e (#PCDATA)>]><cinema><movie> <actor>Some actor</actor> <title>Some title</title> <year>Some year</year></movie></cinema>\[/code\]How would I create an HTML table out of this? I know I can match the root element like this:\[code\]<xsl:template match="/">\[/code\]Then I select all movies like this:\[code\]<xsl:for-each select="/*/*">\[/code\]But how to I know get one row for each movie with three columns for actor, title & year? Especially since the XML file (movie) should be able to maybe only have 2 children or 5.+++EDIT+++If I do this:\[code\]<tr> <td><xsl:value-of select="."/></td></tr>\[/code\]I get each movie's details in one row. This is almost close to what I want to achieve. But how to I spread out the movie details over three columns in that row?
 
Back
Top