Hi Folks
I am using xslt 1.0. I am facing the problem in extracting the element
name and value separately. Any suggestions are welcome
Sample XML:
<state_results state_name="Atlantic Canada" state_id="AC">
- <game_results game_name="Lotto 6/49" game_id="201">
- <date>
<abbr_date>02/03/07</abbr_date>
<full_date>02/03/2007</full_date>
</date>
<number_str>10-13-24-27-37-39, Bonus: 14</number_str>
- <numbers>
<number>10</number>
<number>13</number>
</numbers>
- <bonus>
<bonus_name>Bonus</bonus_name>
<bonus_number>14</bonus_number>
</bonus>
- <next_date>
<next_abbr_date>02/07/07</next_abbr_date>
<next_full_date>02/07/2007</next_full_date>
</next_date>
</game_results>
<requested_action>ADD</requested_action>
</state_results>
My XSL:
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="state_results">
<xsl:for-each select="@*">
<Name><xsl:value-of select="name()"/></Name>
<Value><xsl:value-of select="."/></Value>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Required Output :
<Name>state_name</Name>
<Value>Atlantic Canada</Value>
<Name>state_id</Name>
<Value>AC</Value>
<Name>game_name</Name>
<Value>Lotto 6/49</Value>
<Name>game_id</Name>
<Value>201</Value>
<Name>abbr_date</Name>
<Value>02/03/07</Value>
<Name>full_date</Name>
<Value>02/03/2007</Value>
<Name>number_str</Name>
<Value>10-13-24-27-37-39, Bonus: 14</Value>
<Name>next_abbr_date</Name>
<Value>02/07/07</Value>
I am not able to get desired output.
Regards
Srinivas
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--