Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read a parents' nodes, elements attribute 1

Status
Not open for further replies.

chrish22

Programmer
Apr 30, 2008
4
GB
Hi All

I have a simple question image the following XML

<toplevel>
<toptest odd=”Yes”>
<midlevel>
<midlevel value=”1000”>
</midlevel>
<toplevel>

Midway through my template i am then trying to access a parents' nodes elements attribute like so...

<xsl:for-each select="midlevel">
<xsl:value-of select="../toptest@odd"/>
</xsl:for-each>

Problem is this doesn't work.

I have a work around by using variables but this (invented?) syntax I am using should surely work??? Is it my parser?

Thanks for any help in advance
 
The xml shown is not well-form and should contain typos. Disregarding that, the xpath is incorrect by itself.
><xsl:value-of select="../toptest@odd"/>
[tt]<xsl:value-of select="../toptest[red]/[/red]@odd"/>[/tt]
 
Yes - thank you for correcting me, I have being learning XSLT over the last week or so an am probably suffering information overload ;)

I appreciate XPATH by itself is incorrect, this is just a cut down sample - you wouldn't want to read through 100's of lines of my code!

 
>I appreciate XPATH by itself is incorrect, this is just a cut down sample - you wouldn't want to read through 100's of lines of my code!
I too appreciate that it is a cut down thing; no, I don't want to read them. But what start me thinking is the way to look at one's work. Truth is not conditioned by volumn. A false within 100 lines does not make it a lesser false, true in one line does not make it lesser true. No need of excuse, we make error all the time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top