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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:31:31+00:00 2026-05-14T02:31:31+00:00

After having converted a messed up XML using regex, I now need to change

  • 0

After having converted a messed up XML using regex, I now need to change it yet again.
This source file

<product>
    <sku>SP00001</sku>
    <PID_OWNER_SellerID>StoreName</PID_OWNER_SellerID>
    <EANCode>8711983489813</EANCode>
    <DeliveryDays>2</DeliveryDays>
</product>

Has to become a CSV file, but like this:

sku        field                 value
SP00001    PID_OWNER_SellerID    StoreName
SP00001    EANCode               8711983489813
SP00001    DeliveryDays          2

I take it this is outside of regex’ scope and has to be done with XSL?

  • 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-14T02:31:31+00:00Added an answer on May 14, 2026 at 2:31 am

    Here is some XSLT for you…

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" 
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                    xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
                    exclude-result-prefixes="msxsl"
        >
      <xsl:output method="text" indent="yes"/>
    
      <xsl:template match="/">
        <xsl:call-template name="headerRow" />
        <xsl:apply-templates select="//product" />
      </xsl:template>
    
      <xsl:template name="headerRow">
        <xsl:call-template name="rightpad">
          <xsl:with-param name="fieldvalue" select="'sku'"/>
          <xsl:with-param name="fieldsize" select="number(11)"/>
        </xsl:call-template>
    
        <xsl:call-template name="rightpad">
          <xsl:with-param name="fieldvalue" select="'field'"/>
          <xsl:with-param name="fieldsize" select="number(22)"/>
        </xsl:call-template>
    
        <xsl:text>value&#xd;&#xa;</xsl:text>
      </xsl:template>
    
      <xsl:template match="product">
        <xsl:for-each select="node()[local-name(.) != 'sku']">
    
          <xsl:call-template name="rightpad">
            <xsl:with-param name="fieldvalue" select="../sku"/>
            <xsl:with-param name="fieldsize" select="number(11)"/>
          </xsl:call-template>
    
          <xsl:call-template name="rightpad">
            <xsl:with-param name="fieldvalue" select="local-name(.)"/>
            <xsl:with-param name="fieldsize" select="number(22)"/>
          </xsl:call-template>
    
          <xsl:value-of select="."/>
          <xsl:text>&#xd;&#xa;</xsl:text>
        </xsl:for-each>
      </xsl:template>
    
      <xsl:template name="rightpad">
        <xsl:param name="fieldvalue" select="string('')"/>
        <xsl:param name="fieldsize" select="0"/>
    
        <xsl:variable name="padded" 
                      select="concat($fieldvalue, '                   ')" />
        <xsl:variable name="result" 
                      select="substring($padded,1,$fieldsize)" />
    
        <xsl:value-of select="$result"/>
      </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After having this issue on our websites over secure SSL connections for Office file
I seem to be having two issues with my project after I converted from
After having spent two days attempting to rasterize jpeg's from SVG strings using ImageMagick
After having converted a project from Visual Studio 2005 to Visual Studio 2010, it
After having my last question answered , I have never see the preventDefault(); function
After having a couple of issues getting DQS installed , it appears to be
... after having just read http://www.cocoadev.com/index.pl?CocoaInsecurity ... I am curious to know about your
After having had a dev PC HD corrupt, I'm considering the idea of making
After having worked in MVC for a few months, I'm back in a previously
After having a period of logshipping failures going unnoticed (due to a stopped SQL

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.