Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2013, 05:53 PM
Registered User
 
Join Date: May 2013
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default How to retrive the particular subtags using xslt?

hi,
I have The below xml, in this we are having four <Territory> sub tags.
My problem is how can I retrieve only particular <Territory> tag .
I mean I want to retrieve 2nd and 4th <Territory> values, how can we write XSLT code for it?

<Territories>
<State>FL</State>
<ZipCode>33040</ZipCode>

<Territory>
<City>East Rockland Key</City>
<County>Monroe</County>
<AAISCountyCode>087</AAISCountyCode>
<BusinessAutoTerritory>132</BusinessAutoTerritory>
<BOPTerritory>012</BOPTerritory>
</Territory>

<Territory>
<City>Key West</City>
<County>Monroe</County>
<AAISCountyCode>288</AAISCountyCode>
<BusinessAutoTerritory>193</BusinessAutoTerritory>
<BOPTerritory>01</BOPTerritory>
</Territory>

<Territory>
<City>Key West Naval Air Statio</City>
<County>Monroe</County>
<AAISCountyCode>189</AAISCountyCode>
<BusinessAutoTerritory>172</BusinessAutoTerritory>
<BOPTerritory>042</BOPTerritory>
</Territory>

<Territory>
<City>Stock Island</City>
<County>Monroe</County>
<AAISCountyCode>100</AAISCountyCode>
<BusinessAutoTerritory>122</BusinessAutoTerritory>
<BOPTerritory>092</BOPTerritory>
</Territory>

</Territories>
 
Old May 20th, 2013, 06:17 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You will find it easier to understand the books and tutorials on the subject, and to ask questions, if you learn the terminology of the data model. They aren't "sub tags", they are child elements.

If Territories is the context node, then the XPath expression select="*[2]|*[4]" retrieves the second and fourth child elements.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
[email protected] (May 21st, 2013)





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to retrive image from database gaurav gupta ASP.NET 2.0 Professional 1 July 21st, 2008 10:44 AM
retrive images from a database vindya0121 VB Databases Basics 0 March 23rd, 2006 07:30 AM
retrive file extension Dj Kat Javascript How-To 2 December 10th, 2005 01:35 PM
how to retrive the column properties harshagowda Access 1 December 3rd, 2004 12:13 PM
How do i retrive login name drachx General .NET 6 October 7th, 2004 07:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.