Archiv verlassen und diese Seite im Standarddesign anzeigen : Wert aus einem XML-Tag entnehmen
Hallo!
Ich muss aus so einem Tag: <data danebenNicht="3"/>
den Wert, sprich die Zahl 3 entnehmen.
Mit XSLT.
Aus einem "normalen Tag" ist das ja kein Problem.
Also wenn er so aussieht:
<data>3</data>
Aber bei dem oberen hab ich echt Probleme.
Wie geht denn das??
Ladon
Attributes in the source document can be accessed in a pattern by preceding the attribute name with the @ symbol. The following example extracts the value of the exchange attribute on stock elements and inserts it into the output. For more information about selecting attributes, see XPath.
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<HTML>
<BODY>
<TABLE BORDER="2">
<TR>
<TD>Symbol</TD>
<TD>Name</TD>
<TD>Price</TD>
</TR>
<xsl:for-each select="portfolio/stock">
<TR>
<xsl:attribute name="TITLE"><xsl:value-of select="symbol"/>
is listed on the <xsl:value-of select="@exchange"/>
stock exchange.</xsl:attribute>
<TD><xsl:value-of select="symbol"/></TD>
<TD><xsl:value-of select="name"/></TD>
<TD><xsl:value-of select="price"/></TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
müsste (ohne gewähr) in deinem beispiel also:
<xsl:for-each select="data">
//todo
<xsl:value-of select="@danebenNicht"/> <- gibt "3" aus
//todo
</xsl:for-each>
heissen.
hoffe das hilft ^^
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.