|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
|||
|
|||
|
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>
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XPATH query help ?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|