Hi,

For example my xml looks like this:

<root>
  <Book_information>

    <bookTitle>Lorem 1</bookTitle>

    <choices>test1</choices>
    <choices>test2</choices>
    <choices>test3</choices>
    <choices>test4</choices> 
    <choices>test5</choices>
    <choices>test6</choices>

    <calendar>2010-12-30</calendar>
    <calendar>2011-01-12</calendar>
    <calendar>2011-03-10</calendar>

  </Book_information>
</root>

I need to loop the elements "Choices"... How can i do this? I know how to work with the for each loop, but i don't know how to get the values in choices.

<xsl:for-each select="root/Book_information">
  <xsl:value-of select ="GET THE VALUES IN CHOICES???"/>
</xsl:for-each>

I don't want to use choices[1], choices[2], choices[3],...
because then it would be too much code.

Grts,

Özkan

Grtz

Edited 6 Years Ago by ozkanb: n/a

one Way is use the template go discribe what is doing when the parser
found the node

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="xml"/>
	<xsl:template match="/">
		<found>
			<xsl:apply-templates select="root"/>
		</found>
	</xsl:template>
	<xsl:template match="root">
		<xsl:apply-templates select="Book_information"/>
	</xsl:template>
	<xsl:template match="Book_information">
		<xsl:apply-templates select="choices"/>
	</xsl:template>
	<xsl:template match="choices">
		<item>
			<xsl:value-of select="."/>
		</item>
	</xsl:template>
</xsl:stylesheet>

Result

<?xml version='1.0' ?>
<found>
  <item>test1</item>
  <item>test2</item>
  <item>test3</item>
  <item>test4</item>
  <item>test5</item>
  <item>test6</item>
</found>
This article has been dead for over six months. Start a new discussion instead.