If you are using XSLT1.0, the way to get individual elements is a method called Muenchian Grouping. In your case, you want to "group" by elements of the child elements of the book, so for starters you define a key to search for child elements of books by the name of the element
<xsl:key name="child" match="book/*" use="local-name()" />
To get individual names, you then look at all the child elements of the book, but only display the elements that appear first in the group for their name. You do this using this scary statement:
<xsl:apply-templates select="//book/*[generate-id() = generate-id(key('child', local-name())[1])]" />
Here is the full XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:key name="child" match="book/*" use="local-name()" /> <xsl:template match="/"> <xsl:apply-templates select="//book/*[generate-id() = generate-id(key('child', local-name())[1])]" /> </xsl:template> <xsl:template match="//book/*"> <xsl:value-of select="concat(local-name(), ' ')" /> </xsl:template> </xsl:stylesheet>
When applied to your XML, the following is output:
author title price
Tim c source share