Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old October 26th, 2007, 04:44 AM
Registered User
Join Date: Oct 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating a list depending on a tag value


I have the following xml sample

  <FirstName>Aidan J</FirstName>
  <CoversetHeader>Plan A</CoversetHeader>
  <Cover />
  <AreaOfCover />
  <CoversetHeader>Plan B</CoversetHeader>
  <Cover />
  <AreaOfCover />
  <CoversetHeader>Plan A </CoversetHeader>
  <Cover />
  <AreaOfCover />

I want to extract the FirstName (and store as a variable) only when the Lifestage tag = 'Adult'

How can this be done?


Reply With Quote
  #2 (permalink)  
Old October 26th, 2007, 05:39 AM
mhkay's Avatar
Wrox Author
Points: 18,392, Level: 59
Points: 18,392, Level: 59 Points: 18,392, Level: 59 Points: 18,392, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,947
Thanks: 0
Thanked 288 Times in 283 Posts

First let's get some terminology clear. This:


is an element. It has two tags, a start tag and an end tag. It has an element name (or element type name) of "Lifestage", and a value of "Adult". "Adult" is not the value of either of the two tags. This may all seem pedantic, but it's a lot easier to avoid misunderstandings if people use the correct terminology.

It's not clear what your processing context is, but assuming that your context node is the element that is the parent of the MEMBER_DETAILS elements, then I think you want something like


With your sample data, this path expression will return a node-set containing two elements.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
creating smart tag library Medes VS.NET 2002/2003 0 April 16th, 2006 02:56 PM
creating smart tag library Medes Visual Studio 2005 0 April 10th, 2006 03:29 PM
How to get a list of specific tag from xml using v JelfMaria XML 4 January 13th, 2005 08:34 AM
To get a list of specific tag from xml using v JelfMaria VB How-To 0 January 11th, 2005 06:21 AM
creating a form tag in code marciapz ASP.NET 1.0 and 1.1 Professional 6 August 1st, 2003 06:00 PM

All times are GMT -4. The time now is 02:55 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.