Problem with xml with duplicate tags

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BSKing
    New Member
    • May 2010
    • 1

    Problem with xml with duplicate tags

    I need to create a xls transform for the xml below that would put the items into a table format:

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
    <doc>
      <items>
         <item>a</item>
         <item>b</item>
         <item>c</item>
         <item>d</item>
      </items>
      <items>
         <item>1</item>
         <item>2</item>
         <item>3</item>
         <item>4</item>
      </items>
    </doc>
    table would be like:

    Code:
    <table>
    <tr>
    <td>a</td>
    <td>b</td>
    <td>c</td>
    <td>d</td>
    </tr>
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    </tr>
    </table>
    Is something like this possible?
    Last edited by Dormilich; May 7 '10, 05:41 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    sure, this is possible. basicly it’s about copy & replace.

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      Eg, example:
      Code:
      <xsl:template match="nodeToReplace">
        <newNode>
          <xsl:apply-templates/>
        </newNode>
      </xsl:template>
      Write a template for each node you want to replace, changing 'nodeToReplace' and 'newNode' with the respective node names.

      Comment

      Working...