|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I need some advice from an XSLT/XPath guru please
I need some advice on the best way to approach cross-referencing XML fields. What I'm trying to accomplish is using one element attribute as a key to find a value within a second element.
i.e. <data> <gizmo name="foo1" value="peanuts"/> <gizmo name="foo2" value="walnuts"/> </data> <index> <widget item="Item #1" key="foo1"/> <widget item="Item #2" key="foo2"/> </index> I'd like to be able to loop through the /index/widget elements and list them in the output in a manner similar the following: Item #1 is peanuts Item #2 is walnuts The methods I've tried are very clumsy and I like to see a 'proper' way if one of the guru's here could show me. Thanks. |
|
#2
|
||||
|
||||
|
I'm no guru ... and I haven't used XSL lately.
Code:
<xsl:for-each select "index"> <xsl:value-of select="@item" /> is <xsl:value-of select="/data/gizmo[position()]/@value" /><br /> </xsl:for-each>
__________________
# Jeremy Explain your problem instead of asking how to do what you decided was the solution. |
|
#3
|
|||
|
|||
|
Thanks Jeremy...not quite the solution I needed but thanks for answering anyway...I found a simpler method using the <xsl:key> tag and key() call.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > I need some advice from an XSLT/XPath guru please |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|