XSLT retrieving nodes with a specific child value

advertisements
  <xxx>
      <EntityOverview>
        <LevelId>7</LevelId>
        <LongName>trombone</LongName>
      </EntityOverview>
      <EntityOverview>
        <LevelId>10</LevelId>
        <LongName>bananaphone</LongName>
      </EntityOverview>
    </xxx>

I want to fetch for example the data of LevelId 10 then LevelId 7 to get something like this:

10 bananaphone 7 trombone

Any idea on how to write the XSLT? Im starting to learn

Thanks


If you want to process elements in a different order than giving in the document then you have to apply-templates in the order you want, for instance

<xsl:template match="/">
  <xsl:apply-templates select="//EntityOverview[LevelId = 10]"/>
  <xsl:apply-templates select="//EntityOverview[LevelId = 7"/>
</xsl:template>

Or you can sort on the LevelId e.g.

<xsl:template match="/">
  <xsl:apply-templates select="//EntityOverview">
    <xsl:sort select="LevelId" data-type="number" order="descending"/>
  </xsl:apply-templates>
</xsl:template>

With XSLT 2.0 you can write stuff in a more compact form:

<xsl:template match="/">
  <xsl:apply-templates select="//EntityOverview[LevelId = 10], //EntityOverview[LevelId = 7"/>
</xsl:template>