XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old November 19th, 2003, 08:59 PM
gtp gtp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 1 gtp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old November 20th, 2003, 03:33 PM
teedee teedee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 teedee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Transforming an unknown XML into a table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway