Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XSL select only nodes which contain a specific child node >Thread Next - Re: XSL select only nodes which contain a specific child node Re: XSL select only nodes which contain a specific child nodeTo: NULL Date: 7/8/2009 4:37:00 PM William Krick wrote: > Given the following extremely simplified XML... > > <AA> > <BB></BB> > <BB><CC>foo</CC></BB> > <BB></BB> > <BB><CC>bar</CC></BB> > </AA> > > ...is there an easy way to use and XSL select to get only the <BB> > nodes which have a <CC> child node? > > <xsl:for-each select="AA/BB"> XSLT uses XPath to select nodes and with XPath you can do /AA/BB[CC] to select those 'BB' child elements of the 'AA' root element which have at least one 'CC' child element. With XPath 2.0 you could also write /AA/BB[exists(CC)] which might be clearer and more intuitive for beginners. -- Martin Honnen http://msmvps.com/blogs/martin_honnen/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
