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

  • Home
  • SEARCH
  • 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 6608749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:38:34+00:00 2026-05-25T19:38:34+00:00

I have a 1 time transformation to do to a large XML file. I

  • 0

I have a 1 time transformation to do to a large XML file.

I have :

[stuff]
<items>string1,string2,string3,string4</items>
[other stuff]

I want to replace it with :

<itemList>
    <item>string1</item>
    <item>string2</item>
    <item>string3</item>
    <item>string4</item>
</itemList>

I’m hesitating between using a RegEx or XSL. I’ve been trying to go the regex way :

Search

^.*<items>(.*)</items>

Replace with

<itemList>\1</itemList>

I’m stuck at the “find comma and replace them by something”. I’m not even sure it’s doable…

How could I finish this RegEx? Should I go XSL instead?

  • 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-25T19:38:34+00:00Added an answer on May 25, 2026 at 7:38 pm

    I would use XSLT 2.0.

    XML Input:

    <doc>
      <stuff>sdfsadfsa</stuff>
      <items>string,string,string,string</items>
      <otherstuff>sdfasdfsaf</otherstuff>
    </doc>
    

    XSLT 2.0:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output indent="yes"/>
      <xsl:strip-space elements="*"/>
    
      <xsl:template match="node()|@*">
        <xsl:copy>
          <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="items">
        <itemList>
          <xsl:for-each select="tokenize(.,',')">
            <item><xsl:value-of select="."/></item>
          </xsl:for-each>
        </itemList>
      </xsl:template>
    
    </xsl:stylesheet>
    

    XML Output:

    <doc>
       <stuff>sdfsadfsa</stuff>
       <itemList>
          <item>string</item>
          <item>string</item>
          <item>string</item>
          <item>string</item>
       </itemList>
       <otherstuff>sdfasdfsaf</otherstuff>
    </doc>
    

    If you don’t have an XSLT 2.0 processor, I would suggest Saxon.

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

Sidebar

Related Questions

Question We have a large number of xml configuration files that we want merged
We have a large internal data collection website. I don't have time to create
I have 2 time values which have the type datetime.time . I want to
I have various time-series I'd like to correlate and present as either a csv-file
I have a time interval that spans years and I want all the time
I have an data transformation query which takes a long time to run on
Thanks in advance for your time. I have a deeply nested XML whose XSLT
I have a bunch of measurements over time and I want to plot them
Here's the scenario. We use a large XML configuration file for one of our
I have a large CSV file (5.4GB) of data. It's a table with 6

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.