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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:22:58+00:00 2026-05-29T09:22:58+00:00

I am trying to use XSL to transform an XML file and can’t figure

  • 0

I am trying to use XSL to transform an XML file and can’t figure out how to rename an element as either the name or value of one of its attributes. I have found plenty of examples of converting attributes to elements and the other way around but I keep ending up with elements that are nested which I don’t want. Here is an example:

Original XML:

<row_item column="Hostname">HOST-A</row_item>
<row_item column="IP Address">10.10.10.10</row_item>

What I would like to output:

<column>HOST-A</column>

Or (preferred):

<hostname>HOST-A</hostname>

  • 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-29T09:22:59+00:00Added an answer on May 29, 2026 at 9:22 am

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="row_item[1]">
         <xsl:element name="{@column}">
          <xsl:value-of select="."/>
         </xsl:element>
     </xsl:template>
     <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    when applied on this XML document:

    <rows>
        <row_item column="Hostname">HOST-A</row_item>
        <row_item column="IP Address">10.10.10.10</row_item>
    </rows>
    

    produces the wanted, correct result:

    <Hostname>HOST-A</Hostname>
    

    Explanation:

    Appropriate use of xsl:element and AVT.

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

Sidebar

Related Questions

I'm trying to use an XSL file to transform an XML file into an
I'm trying to use XSL-stylesheets in order to transform some generated XML-data to HTML-output.
I am trying to use Javascript to transform part of a XML file to
In my XSLT file. I use the document() function <xsl:variable name=Publicity select=document('./publicity.xml') /> and
I am trying to use VBScript to do an XSLT transform on an XML
I'm trying to use XML files and XSL stylesheets instead of ordinary phtml templates
What I am trying to do is use XSL to output all unique element
I am trying to use XSL to transform the following WCF call and place
I'm trying to use a .xsl file so that it will return a HTML
So, I'm trying to use XMLResolver to load an xml file. It works fine

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.