xsl-list
[Top] [All Lists]

XML Root Element

2005-03-04 15:00:00
Is there a way I can get the name of the root element?
 For example, in the following xml:
-------------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type='text/xsl' href='my.xsl'?>
<myxmlroot>
  <sometag></sometag>
</myxmlroot>
-------------------------------------------------

Is there a way I can get the string "myxmlroot" which
is the name of my root element?

I have tried doing something like this via my.xsl:
-------------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/">
  <xsl:value-of select="name()"/>
</xsl:template>
</xsl:stylesheet>
-------------------------------------------------


The name() function does not work by putting it in the
"/" template.  It prints the documents root (system
root I think?) and not the root element name which is
what I want.  How do I get to this?

Thanks,
C


        
                
__________________________________ 
Celebrate Yahoo!'s 10th Birthday! 
Yahoo! Netrospective: 100 Moments of the Web 
http://birthday.yahoo.com/netrospective/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>