xsl-list
[Top] [All Lists]

Re: Get a comma delimited string of nodenames.

2003-04-02 22:02:34
Lainaus S K <shishirpradnya(_at_)hotmail(_dot_)com>:

| Hi I have an xml like this:
| 
| <?xml version="1.0" ?>
| <root>
|    <data_field1>value1</data_field1>
|    <data_field2>value1</data_field2>
|    <data_field3>value1</data_field3>
|    <data_field4>value1</data_field4>
| </root>
| 
| I am trying to get back a string in the form:
| 
| "data_field1,data_field2,data_field3,data_field4"
| 
| Any help will be appreciated...
| 
| -Shishir
| 
| 
| _________________________________________________________________
| Protect your PC - get McAfee.com VirusScan Online  
| http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
| 
| 
|  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| 
| 

<xsl:stylesheet 
        xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"; version = "1.0" >
          <xsl:output method = "text" />
          <xsl:template match = "root" >
               <xsl:for-each select="*">
               <xsl:value-of select = "local-name()" />
               <xsl:if test = "not(position()=last())" >
                    <xsl:text >, </xsl:text>
               </xsl:if>
               </xsl:for-each>
          </xsl:template>
</xsl:stylesheet> 

will output: data_field1, data_field2, data_field3, data_field4

Modify it to confront your exact needs.

Cheers, 
Jarkko


***************************************************
* Jarkko Moilanen                                 *
* Project Researcher, ITCM (www.itcm.org)         *
* Profound XML technology Expert                  *
* University of Tampere                           *
* Hypermedia Laboratory                           *
***************************************************

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>