1

I have an XML with data as follows

<Item1>
  <item2>
    <Item3>111</Item3>
  <Item2>
</Item11>

To get the value 111 in Item3

<xsl:choose>
  <xsl:value-of select="Item1/Item2/Item3"/>
</xsl:choose>

In XSLT . Now I need to get the following:

<Product1>
  <Product2>
    <Product3 ValidYN="Y" ProducType="ABC">333</Product3>
    <Product3 ValidYN="Y" ProducType="DEF">444</Product3>
    <Product3 ValidYN="Y" ProducType="GHI">555</Product3>
  <Product12>
</Product1>

I need to take values 333 , 444 , 555 based on ProducType.How to do the same using XSLT

dany
  • 1,801
  • 7
  • 27
  • 40
  • What do you mean when you say "take" those values based on ProducType? What should the result of the XSLT look like? – JLRishe Mar 21 '13 at 13:44
  • Using first sample I was able to reach to value **111** .Now I need to get values 333,444,555 but the xml tags are similar for those except ** ProducType="ABC" ,ProducType="DEF" ,ProducType="GHI"** .What will be the code for reach these values ,similar to `` – dany Mar 21 '13 at 13:50

1 Answers1

1

To select a node based on values in relation to it, you can use XPaths like this:

/Product1/Product2/Product3[@ValidYN = 'Y' and @ProductType = 'ABC']
/Product1/Product2/Product3[@ValidYN = 'Y' and @ProductType = 'DEF']
/Product1/Product2/Product3[@ValidYN = 'Y' and @ProductType = 'GHI']

the parts in [square brackets] are called "predicates."

JLRishe
  • 99,490
  • 19
  • 131
  • 169