RE: [xsl] How do I pull out an element name out for use as a a printed variable

Subject: RE: [xsl] How do I pull out an element name out for use as a a printed variable
From: "Eric Schenfeld" <ESchenfeld.LISC_DC_PO.LISC_DC@xxxxxxxxxxx>
Date: Fri, 22 Jun 2001 16:41:21 -0400
ok, i solved my own problem but thought that it might be nice to post how in case someone else needs it.

Recap:

-I have the following XML structure:
-<contacts>
-<contact>
 -    <name>xxxx</name>
-     <title>Program Director</title>
-     <phone>xxx.xxx.xxxx</phone>
-     <email>
-      <link mailto:href="mailto:xxxxxxx@xxxxxxxxxxx>xxxxxxx@xxxxxxxxxxx</link>
-     </email>
-</contact>
-<contact>.....</contact>
-</contacts>
-
-The children elements of contact vary slightly between different contact lists.  Because of this, 
-the tables in which they appear should often have different headers (which would just be the 
-name of that child element... ie name, title, phone, email ... in this case).  I tried using the 
-recommendation in the FAQ under the first table section but i couldn't get it to work for children 
-elements instead of the attributes.  Any help is appreciated.
-eric

Solution:

<xsl:for-each select="contact[1]/*">
  <td>
    <xsl:value-of select="name(.)"/>
  </td>
</xsl:for-each>

Eric



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread