XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 20th, 2004, 04:32 AM
Johnboy_Endy Johnboy_Endy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 Johnboy_Endy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XPATH query help ??

Hi,

I am wanting to query the following XMl document with a user id, using XPATH, and return a list of the section type's.

eg. if i submitted john i would get General and if i submitted Bill i would get General Author.

I think this has something to do with parent:: but cant work it out.

Hopefully some of you guys might have an idea, save me a few days of pain!!!!

Thanks


<menu>

<section type="General">
<users>
<userid>john</userid>
<userid>Bill</userid>
</users>
<link href="home.aspx">
<Text>Home</Text>
</link>
<link href="navigation.aspx">
<Text>Navigation</Text>
</link>
</section>

<section type="Author">
<users>
<userid>Frank</userid>
<userid>Bill</userid>
</users>
<link href="authors.aspx">
<Text>View Author</Text>
</link>
<link href="authNews.aspx">
<Text>Author News</Text>
</link>
</section>
</menu>

Reply With Quote
  #2  
Old May 21st, 2004, 02:23 AM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 282 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 2 h 30 m 42 sec
Reputation Power: 6
The following stylesheet demonstrates how to find the section types for a particular userid.

Code:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<!-- the selected user -->
<xsl:variable name="user" select="'Bill'" />

<xsl:template match="/">
   <xsl:call-template name="find" >
      <xsl:with-param name="user" select="$user" />
   </xsl:call-template>
</xsl:template>

<xsl:template name="find" >
   <xsl:param name="user" />
   User: <xsl:value-of select="$user" />
   <xsl:for-each select="//section[//userid=$user]/@type" >
       Section: <xsl:value-of select="."/>
   </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XPATH query help ??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT