A: 

Your xslt will be

<xsl:template match="/rootnode">
    <xsl:for-each select="child">
        <xsl:if test="contains(@id,'child')">
        ... do your stuff here....
        </xsl:if>
    </xsl:for-each>
</xsl:template>

You can also use starts-with function see http://www.w3schools.com/xpath/xpath_functions.asp for complete reference

ajay_whiz
I want to iterate only through the child node having id like 'child'ie it should return only me the child node [child1,child2,child3,child3,child4,child5,child6]
Amit Shah
@Amit added a if clause
ajay_whiz
I got your solution,But I have more than 2000 child node. If there is no other way,I will go with it as "something is better than nothing"Thanks for your response.
Amit Shah
@Amit not sure if you could do something like <xsl:for-each select="child[contains(@id,'child')=true]">
ajay_whiz
+1  A: 

Its worth learning to not just reach for a for each loop in XSLT - this is a template matching approach to the same thing:

<xsl:template match="/rootnode">
    <xsl:apply-template select="child[starts-with(@id, 'child')]" />
</xsl:template>

<xsl:template match="child">
    <!-- Do stuff -->
</xsl:template>

The key bit is the xpath query in square brackets - something that ajay_whiz also suggested for the for-each loop.

Murph
+1  A: 

For efficiency you could define a key and use that e.g.

<xsl:key name="k1" match="child" use="starts-with(@id, 'child')"/>

<xsl:template match="rootnode">
  <xsl:for-each select="key('k1', true())">
    ...
  </xsl:for-each>
</xsl:template>
Martin Honnen
@Martin Honnen: +1 This is a good answer. But, don't recommend `for-each` instruction when there is no need.
Alejandro