• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Using Attributes in XSLT

 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This shouldn't be too hard for someone.
Say I have some XML:
<somexml>
<sometag foo="stuff">differentstuff</sometag>
</somexml>
Now I want a template that will give me
<html>
. . .
<body>
<h1> somexml </h1>
<table>
<tr><td>stuff</td><td>differentstuff</td><tr>
</table>
If someone could give me a clue how to get the name of the element and the value of the attribute, I'd be much obliged.
regards
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Andrew Shafer:
This shouldn't be too hard for someone.


Thank you!
That should work:
<html>
. . .
<body>
<h1> somexml </h1>
<table>
<tr><td><xsl:value-of select="somexml/sometag/@foo"/></td>
<td><xsl:value-of select="somexml/sometag"/></td><tr>
</table>
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!