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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL-Select Vaule when ID="X" in loop 1

Status
Not open for further replies.

Snug

MIS
Sep 5, 2001
59
0
0
US
Please look at the XML data below.

I am having difficulties trying to select the "Value" (<xsl:value-of select="Value"/>) when the ID="-2". The Var loops many times, but I only want the Value when EITHER the ID="-2" or the Name="PV_FloorPlanCODE".

I'm not very experienced, I've tried an If statment, Choose, ..etc. I cannot get anything to work.

Thank you in advance!!
Snug

Here is the looping data from the XML..
<Var ID="-2" type="String">
<Value>APC</Value>
<Name><![CDATA[PV_FloorPlanCODE]]></Name>
</Var>
<Var ID="-7" type="String">
<Value>0</Value>
<Name><![CDATA[PV_FMTPOSitionSTart]]></Name>
</Var>
 
One uses a predicate
Code:
value="Value[../@ID='-2' or ../Name='PV_FloorPlanCODE']"

or, alternatively
Code:
value="Var[@ID='-2' or Name='PV_FloorPlanCODE']/Value"

What you use depends on what your context node is at the time. These two illustrations should give you the idea, however. You can place a constraint on whether a node participates in the node set by placing a boolean expression inside square brackets. Read about predicates here.


Tom Morrison
 
Thank you Tom!! Here's the code that works incase anyone else has the same problem.

<xsl:value-of select="Var[@ID='-2']/Value"/>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top