Re: [xsl] Print all root node attributes

Subject: Re: [xsl] Print all root node attributes
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Sun, 29 May 2005 21:06:42 +0200
Frequent Fliers wrote:
Hi i use the following snippet to print the root node name, but im also trying to retrieve all the associated attributes of the root node, if any.

Well, you can't do this, because the root node of an XML tree doesn't have a name nor attributes. You mean the document element, also often called root element (but *never* root node, unless you want to confuse people).

<xsl:for-each select="*">
  <xsl:value-of select="name()" />
      <xsl:for-each select="@*">
         <xsl:value-of select="current()" />

The current() function returns the node matched by the template. Try <xsl:value-of select="." /> instead.

J.Pietschmann

Current Thread