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 8384255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:21:41+00:00 2026-06-09T17:21:41+00:00

I am converting my XML file to CSV using XML2CSV The XML format can

  • 0

I am converting my XML file to CSV using XML2CSV

The XML format can be simplified to

<PersonalInfo>
    <UserDetail>
       <FirstName>ABC</FirstName>
       <Occupation>Student</Occupation>
       <DateOfBirth>08/14/1999</DateOfBirth>
    </UserDetail>
    <CaseDetail>....</CaseDetail>
    <TransactionDetail></TransactionDetail>
</PersonalInfo>      
<PersonalInfo>
    <UserDetail>
       <FirstName>XYZ</FirstName>
       <Occupation>Student</Occupation>
       <DateOfBirth>04/25/1991</DateOfBirth>
     </UserDetail>
     <CaseDetail>....</CaseDetail>
     <TransactionDetail></TransactionDetail>
</PersonalInfo>      
<PersonalInfo>
    <UserDetail>
        <FirstName>DEF</FirstName>
        <Occupation>Teacher</Occupation>
        <DateOfBirth>05/12/1984</DateOfBirth>
    </UserDetail>
    <CaseDetail>....</CaseDetail>
    <TransactionDetail></TransactionDetail>
</PersonalInfo>      

While using the XML to CSV converter i only want to convert those fields where the Occupation tag has value of Student. Is it possible through this or i have to use some other script to make a final xml file, then convert that to CSV. Any Ideas.

EDIT: Only Values of FirstName, Occupation and DateOfBirth are needed. No value from CaseDetail or TransactionDetail should be in the resultant file.
The format of the end file should be like

 ABC|Student|08/14/1999 
 XYZ|Student|04/25/1991
  • 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-06-09T17:21:43+00:00Added an answer on June 9, 2026 at 5:21 pm

    Extending my comment to a real answer now. Here’s the xslt I used to convert the xml to csv directly. (I used libxml2’s xsltproc to do the actual conversion)

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:output method="text"/>
      <xsl:strip-space elements="*"/>
    
      <xsl:template match="PersonalInfo">
        <!-- causes only UserDetail nodes to be processed -->
        <xsl:apply-templates select="UserDetail"/>
      </xsl:template>
    
      <xsl:template match="UserDetail[Occupation='Student']">
        <xsl:value-of select="FirstName"/>
        <xsl:text>,</xsl:text>
        <xsl:value-of select="Occupation"/>
        <xsl:text>,</xsl:text>
        <xsl:value-of select="DateOfBirth"/>
        <xsl:text>&#0010;</xsl:text>
      </xsl:template>
    
      <!-- catch all the other userdetail here -->
      <xsl:template match="UserDetail"/>
    
    </xsl:stylesheet>
    

    applied to your xml this gives:

    ABC,Student,08/14/1999
    XYZ,Student,04/25/1991
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm converting a csv file to xml using the following function: I want to
I've solved my previos problem of converting XML RSA private key to PEM file,
Possible Duplicate: Converting XML to JSON using Python? I'm doing some work on App
I am converting a xml using xslt. Original XML is <Content> <book> <customData> <CustomDataElement>
I am have trouble converting my xml using XSLT back to xml in the
So I have this huge XML file that I am converting to an object
I really need some help on an issue: I'm converting an XML to CSV
I really need some help on an issue: I'm converting an XML to CSV
Im trying to load a csv file into a datatable using oledb. This is
I am trying to use XSL to transform an XML file and can't figure

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.