<CCAddMFADetailsRequest>
<accounts>
<tp_account>
<tp_account_id> 28 </tp_account_id>
<questions>
<question>
<text>Enter your first pet's name:</text>
<answer>tiger</answer>
</question>
<question>
<text>Enter your first pet's name2:</text>
<answer>tiger2</answer>
</question>
<question>
<text>Enter your first pet's name3:</text>
<answer>tiger3</answer>
</question>
</questions>
</tp_account>
<tp_account>
<tp_account_id> 29 </tp_account_id>
<questions>
<question>
<text>Enter your 9</text>
<answer>dsftiger</answer>
</question>
</questions>
</tp_account>
</accounts>
</CCAddMFADetailsRequest>

How to get number of <tp_account_id> and questions related to those accounts from above XML document

creat a textfile

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="text"/>
	<xsl:template match="/">
		<xsl:apply-templates select="CCAddMFADetailsRequest"/>
	</xsl:template>
	<xsl:template match="CCAddMFADetailsRequest">
		<xsl:apply-templates select="accounts"/>
	</xsl:template>
	<xsl:template match="accounts">
		<xsl:apply-templates select="tp_account"/>
	</xsl:template>
	<xsl:template match="tp_account">
		<xsl:value-of select="concat(tp_account_id,'&#xA;')"/>
		<xsl:apply-templates select="questions"/>
	</xsl:template>
	<xsl:template match="questions">
		<xsl:apply-templates select="question"/>
	</xsl:template>
	<xsl:template match="question">
		<xsl:value-of select="concat(text,' : ',answer,'&#xA;')"/>
	</xsl:template>
</xsl:stylesheet>

result

28
Enter your first pet's name: : tiger
Enter your first pet's name2: : tiger2
Enter your first pet's name3: : tiger3
29
Enter your 9 : dsftiger
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.