I am having some difficulty selecting the correct value in my loop.
my loop does not retrieve the associated values.
Resume of File.xml
<WKIUserSpecifiedAttributesRoot>
<EntityRef Ref_ID="ID_17">
<Attribute name="Difficulty" >
<Value>Low</Value>
</Attribute>
<Attribute name="Title" >
<Value> 5 </Value>
</Attribute>
</EntityRef>
<EntityRef Ref_ID="ID_19">
<Attribute name="Difficulty" >
<Value>hight</Value>
</Attribute>
<Attribute name="Title" >
<Value> 10 </Value>
</Attribute>
</EntityRef>
</WKIUserSpecifiedAttributesRoot>
file.xslt
<xsl:for-each select="$P_DataXMLRoot/WKIPreviewDataRoot/WKIUserSpecifiedAttributesRoot/EntityRef">
<xsl:value-of select="//Attribute[@name = 'Title']" />
<xsl:value-of select="//Attribute[@name = 'Difficulty']" />
</xsl:for-each>
I recover many values but not the one that corresponds to the Ref_Id, All my data are the same.
I only provide 2 Entity_Refs in the example but I have many more but only the value of the first Entity_Ref appears in all the results of the loop.
Thank you Verry Much.
>Solution :
From the posted XML, you would want something like this :
<xsl:for-each select="$P_DataXMLRoot/WKIUserSpecifiedAttributesRoot/EntityRef">
<xsl:value-of select="Attribute[@name = 'Title']/Value" />
<xsl:value-of select="Attribute[@name = 'Difficulty']/Value" />
</xsl:for-each>
Using // goes back to the beginning of your document and traverses it to find all elements corresponding to your XPath.