Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:54:04+00:00 2026-05-24T19:54:04+00:00

i am trying to convert XML to csv using xslt, i am not familiar

  • 0

i am trying to convert XML to csv using xslt, i am not familiar with xslt so just reading some tutorial and other online resources.
Here is my XML

<?xml version="1.0" encoding="UTF-8"?>
<impex>
    <test>
        <Employee />
        <UID>auma</UID>
        <Name>HR Manager</Name>
        <Groups />
        <Password>228781</Password>
    </test>
    <test>
        <Employee />
        <UID>auma1</UID>
        <Name>HR Manager</Name>
        <Groups />
        <Password>2287811</Password>
    </test>
</impex>

i am using the following XSL for the conversion of xml to csv

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:f="Functions"
  version="2.0">

<xsl:output method="text" />
 <xsl:param name="headerVal" select="'INSERT_UPDATE Employee;UID[unique=true];name;groups(uid);password'"/>


<xsl:template match="/impex">
     <xsl:apply-templates select="test[1]/*" mode="header"/>
    <xsl:apply-templates select="test" />
</xsl:template>


<xsl:template match="*" mode="header" >

    <xsl:value-of select="$headerVal" />
</xsl:template>

<xsl:template match="test">
    <xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="*" >
    <xsl:value-of select="."/>
    <xsl:choose>
        <xsl:when test="position()=last()">
            <xsl:text>&#10;</xsl:text>
        </xsl:when>
        <xsl:otherwise>;</xsl:otherwise>
    </xsl:choose>
</xsl:template>


</xsl:stylesheet>

i am trying to define my csv header using but this is not working for me

csv output

INSERT_UPDATEEmployeeUID[unique=true]namegroups(uid)password
INSERT_UPDATEEmployeeUID[unique=true]namegroups(uid)password
INSERT_UPDATEEmployeeUID[unique=true]namegroups(uid)password
INSERT_UPDATEEmployeeUID[unique=true]namegroups(uid)password
INSERT_UPDATEEmployeeUID[unique=true]namegroups(uid)password
;auma;HR Manager;;228781
;auma1;HR Manager;;2287811

as below line

<xsl:param name="headerVal" select="'INSERT_UPDATE Employee;UID[unique=true];name;groups(uid);password'"/>

I was assuming that it was due to ; in the select value but i even removed it and even removed the space but nothing helped
i have googled about this but unable to find a way as how to define this header inside my xsl file so that i can use this header for my csv

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:54:06+00:00Added an answer on May 24, 2026 at 7:54 pm

    Problem resolved.

    <xsl:apply-templates select="test[1]/*" mode="header"/>
    

    Here I was selecting all elements inside test[1] and in my XML I have five elements inside the test element, so I just changed this line to:

    <xsl:apply-templates select="test[1]" mode="header"/>
    

    and it working fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert some xml into a json object using PHP. This
I am trying to convert an HTML file into XML file using XSLT (Using
I'm trying to convert a XML file to CSV using PHP, but I have
I'm trying convert xml from one format to other using the XslCompiledTransform in c#.
I am trying to convert some JSON to XML and then save it using
I'm trying to convert an XML file into the markup used by dokuwiki, using
I am trying to convert an Xml String to XML DOM object using Xerces
I am trying to use powershell to convert a csv to an xml table.
I am trying to convert an XML file to CSV, but the encoding of
Hi I'm trying to convert the XML file into associative array by using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.