0

<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

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by xml_looser
0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.