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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:14:04+00:00 2026-06-02T13:14:04+00:00

I have a some xml fields i need to concatenate all the fields in

  • 0

I have a some xml fields i need to concatenate all the fields in one field

<fields>
<field name="first"><value>example</value></field>
<field name="last"><value>hello</value></field>
<field name="age"><value>25</value></field>
<field name="enable"><value>1</value></field>
<fields>

i need to transform as following

<fields>
<field name="all"><value>example hello 25 1</value></field>
</field>

with space delimiter using 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-06-02T13:14:05+00:00Added an answer on June 2, 2026 at 1:14 pm

    This short and simple (no explicit conditional instructions) XSLT 1.0 transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/*">
      <fields>
        <field name="all">
          <xsl:variable name="vfieldConcat">
            <xsl:for-each select="field/value">
              <xsl:value-of select="concat(., ' ')"/>
            </xsl:for-each>
          </xsl:variable>
          <value><xsl:value-of select=
             "normalize-space($vfieldConcat)"/></value>
        </field>
      </fields>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document (corrected for well-formedness):

    <fields>
        <field name="first">
            <value>example</value>
        </field>
        <field name="last">
            <value>hello</value>
        </field>
        <field name="age">
            <value>25</value>
        </field>
        <field name="enable">
            <value>1</value>
        </field>
    </fields>
    

    produces the wanted, correct result:

    <fields>
       <field name="all">
          <value>example hello 25 1</value>
       </field>
    </fields>
    

    II. XSLT 2.0 solution

    <xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/*">
      <fields>
        <field name="all">
          <value><xsl:value-of select="field/value"/></value>
        </field>
      </fields>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the same XML document (above), the same correct result is produced:

    <fields>
       <field name="all">
          <value>example hello 25 1</value>
       </field>
    </fields>
    

    Explanation: Using the fact that the default value for the separator attribute of xsl:value-of is a single space.

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

Sidebar

Related Questions

I have a SQL table with some normal fields and one xml-type field. I
I have some xml like this: <Data> <Rows> <Row> <Field Name=title>Mr</Field> <Field Name=surname>Doe</Field> <Row>
I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>
I have some xml documents I need to run queries on. I've created some
I have some xml and need to extract values using sql <?xml version=1.0 ?>
I have a class that I need to do some custom XML output from,
I have a table called People one of the columns is an xml field
I have some XML in the following schema: <Form ID=1 Formtitle=Title> <Fields> <Fieldset Legend=LegendText
I need to work with XML documents and I need to copy some fields
I have some XML in an XmlDocument, and I want to display it on

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.