XSLT axis navigation

A Amitkashaw

Usenet Archive
Joined
Nov 6, 2003
Messages
2
Reaction score
0
Hi Everyone.

I'm having a few problems with the following XSL statement -

<xsl:template match="htm:div[text='Fred's List of Things:']"> <xsl:for-each select="../following-sibling::*/child::htm:i[text='Guitars:']"> <xsl:value-of select="text"/> </xsl:for-each> </xsl:template>

It returns the ELEMENT 'Guitars:' but what I need is the text after it. I'm stumped if I can figure out how to get this value to return. The reason why I'm using the above XML is because there are lots of other <i> ELEMENTS within the document with the text 'Guitars:' and I need Fred's guitar choice specifically.

Here's the XML:

- <td>
<div align="right">Fred's List of Things:</div>
</td>

<td>
<i>Hobbys:<i>
Reading, Writing, painting, riding bikes
<br />
<i>Books I have read:</i>
Animal Farm,
<br />
<i>Guitars:</i>
1 Gibson Les Paul
<br />
<i>Cars:</i>
None, I like riding my bike everywhere
<br/>
</td>

Thanks for your time in this matter.

- S
 

Patrick TJ McPhee

Usenet Archive
Joined
Apr 2, 2000
Messages
269
Reaction score
0
% select="../following-sibling::*/child::htm:i[text='Guitars:']">

% It returns the ELEMENT 'Guitars:' but what I need is the text after it.

where the element in question is like this

% <i>Guitars:</i>
% 1 Gibson Les Paul
% <br />

you could try appending

/../following-sibling::/text[1]

to your expression. That should get everything up to the <br/>.
 

Skaffen Amitkashaw

Usenet Archive
Joined
Nov 18, 2003
Messages
2
Reaction score
0
Thanks, Patrick.

How good are you with the number function? I'm trying to return mixed numbers and string. For example: 45 km. Do I need to strip out the 'km' or does the number function take care of this for me?

Thanks again for your time :)

- S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top