Help with Looping

Joined
Apr 6, 2010
Messages
2
Reaction score
0
PLZ HELP!!!!

For the following XML needed a output as detailed below. Will be great help for me. Thanks in Advance.

<SubEligBenInfo>
<sSubDateTimeType2110>
<string>Completion</string>
<string>Expires</string>
<string xsi:nil="true" />
<string xsi:nil="true" />
<string xsi:nil="true/>
</sSubDateTimeType2110>
<sSubDateTimeFormat2110>
<string>CCYYMMDD</string>
<string>YYMMDD</string>
<string xsi:nil="true" />
<string xsi:nil="true" />
<string xsi:nil="true" />
</sSubDateTimeFormat2110>
<sSubDateTimePeriod2110>
<string>20050401</string>
<string>20060401</string>
<string xsi:nil="true" />
<string xsi:nil="true" />
<string xsi:nil="true" />
</sSubDateTimePeriod2110>
</SubEligBenInfo>

OUTPUT:

Completion
CCYYMMDD
20050401

Expires
YYMMDD
20060401
 
Joined
May 15, 2010
Messages
5
Reaction score
0
Hello,

I am not sure what your are trying to acheive. Besides the string elements that are empty with same value attributes, the other string elements have unique parent nodes. So I can't see any looping here. Now here is an partial xsl (this thing does not allow xmlns links etc...) giving your ouput with no loop. I removed the empty string elements from xml.

Code:
	<!-- Override default template behaviour i.e. do display str elemnts -->
	<xsl:template match="string" />
	
	<xsl:template match="/SubEligBenInfo">
		<html>
			<head>
				<title>Insert Your Title Here</title>
			</head>
			<body>
				<!-- TODO: Auto-generated template -->
				<xsl:value-of select="sSubDateTimeType2110/string[1]" />
				<br />
				<xsl:value-of select="sSubDateTimeFormat2110/string[1]" />
				<br />
				<xsl:value-of
					select="sSubDateTimePeriod2110/string[1]" />
				<br />
				<br />
				<xsl:value-of select="sSubDateTimeType2110/string[2]" />
				<br />
				<xsl:value-of select="sSubDateTimeFormat2110/string[2]" />
				<br />
				<xsl:value-of select="sSubDateTimePeriod2110/string[2]" />

			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>

hope this will help
 
Joined
May 15, 2010
Messages
5
Reaction score
0
more loop

You can also avoid hard coding the indices 1 and 2 by using a call template that works recursively like a for loop ;-)

aljar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top