Jump to content

Recommended Posts

Hello,first sorry for my bad english, i am from germany. I have a xml file (this is just a example)

<ROWDATA><ROW  NAME="Dert*Test*Nr1" GRUPPE ="Gut*&*fein" /><ROW  NAME="Dert*Test*Nr2" GRUPPE ="lecker*&*fein" /><ROW  NAME="Dert*Test*Nr3" GRUPPE ="lecker*&*fein" /><ROW  NAME="Dert*Test*Nr4" GRUPPE ="Gut*&*fein" /></DATAPACKET></ROWDATA>

now i want to read out the NAME attribut, according to the right GRUPPE attribut.For example, if i want to have "Der Test Nr2"

<text>	 <xsl:for-each select="/DATAPACKET/ROWDATA/ROW">	  <xsl:if test="/DATAPACKET/ROWDATA/ROW/@GRUPPE = 'lecker*&*fein' ">	   <xsl:value-of select="/DATAPACKET/ROWDATA/ROW/@NAME"/>	  </xsl:if>	 </xsl:for-each>   </text>

but this dont work :-(

Link to post
Share on other sites

<xsl:value-of select="/DATAPACKET/ROWDATA/ROW[@gruppe='lecker*&*fein']/@NAME"/> Mit der eckigen Klammer kannst du "Predicates" setzten , d.h. deine Auswahl einschränken. Du kannst z.B. bestimmte Attributwerte nennen oder einen Wert abfragen, also so etwas wie "immer wenn der Preis höher als 10 Euro ist" etc.Mit dem /@name wählst du dann lediglich noch die gewünschte Ausgabe....Die If Abfrage ist somit hinfällig, da du schon bei"value-of" entsprechend selektierst...

Edited by mbr
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...