|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Transforming an unknown XML into a table
If I had an XML file like this:
<root> <student> <name>Bill</name> </student> </root> and I can display it as a table using XSLT but a few days later i may want something like this: <root> <student> <surname>Clinton</surname> <name>Bill</name> <age>50</age> <sex>M</sex> </student> </root> ...is it possible for an XSLT to accept and transform an XML file that will have varying number of child-nodes and display it on a table. All I know is that it will involve wildcards and loops - not much, I know ![]() I've searched around the web and considered using <xls:for-each> & <xsl:apply-templates> but cannot come up with an idea. Any indication of whether this is possible or how it can be achieved is appreciated. |
|
#2
|
|||
|
|||
|
If you want to reference elements or attributes without specifying their name then you need to use xsl axes:
Code:
<table> <xsl:for-each select="/root/student"> <tr> <xsl:for-each select="child::*"> <td> <xsl:value-of select="."/> </td> </xsl:for-each> </tr> </xsl:for-each> </table> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Transforming an unknown XML into a table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|