|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
displaying all attributes
Hi
I have recently started experimenting with xpath/xslt. I have a problem displaying all the attributes from a xml file Here is my xml file <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="employee.xsl"?> <source> <AAA pos="start" id="a1"> <BBB id="b1"/> <BBB/> </AAA> <AAA id="a2"> <BBB id="b3"/> <BBB dsids="b4" dfhk="b6"/> <CCC id="c1"> <DDD id="d1"/> </CCC> <BBB idt="b5"> <CCC id="c2"/> </BBB> </AAA> </source> My xslt file looks like this <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match="/"> <xsl:for-each select="//*[@*]"> <DIV style="color:red"> <xsl:value-of select="name()"/> <xsl:text> </xsl:text> <xsl:value-of select="name(@*)"/> <xsl:text> = </xsl:text> <xsl:value-of select="@*"/> </DIV> </xsl:for-each> </xsl:template> </xsl:stylesheet> The output is AAA pos = start BBB id = b1 AAA id = a2 BBB id = b3 BBB dsids = b4 CCC id = c1 DDD id = d1 BBB idt = b5 CCC id = c2 Some elements (AAA,BBB) have 2 attributes but in the output only the first attribute is displayed. How can I display both the attributes. Last edited by hade : August 7th, 2003 at 06:26 AM. |
|
#2
|
||||
|
||||
|
Try this:
Code:
<xsl:for-each select="//*">
<xsl:value-of select="name()"><xsl:text> </xsl:text>
<xsl:for-each select="@*">
<xsl:value-of select="name()"><xsl:text> </xsl:text><xsl:value-of select=".">
</xsl:for-each>
</xsl:for-each>
Please let me know if it works... |
|
#3
|
|||
|
|||
|
Thanks a lot. It works fine
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > displaying all attributes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|