Beginner - Need help with a simple XML to XML by XSLT

Sorry, I'm a true beginner and I plan to take some classes, But I have this quick question.  This is a small sample of the code.

     <MissionInfo Name="YtYtYtYt">
Needed Result:
     <MissionInfo Name="YtYtYtYt">

My code:
      <MissionInfo><xsl:value-of select="MissionInfo/@Name"/>

My result:
Who is Participating?
mccarlConnect With a Mentor IT Business Systems Analyst / Software DeveloperCommented:
The <xsl:value-of .../> just puts the content directly into the output XML in whatever context you are currently in. Hence why you are getting what you have, the <xsl:value-of> is inside the MissionInfo element and so the content just goes inside that element in the output.

You will need to use the <xsl:attribute ...> element to identify an attribute (eg. Name) that you are trying to set and then you can use the <xsl:value-of .../> inside that to set that attribute to whatever you want.

So for this you would do...
   <xsl:attribute name="Name">
      <xsl:value-of select="MissionInfo/@Name"/>

Open in new window

Nancy_McIverAuthor Commented:
Thanks so much!  I knew if I could ask a question I could find out quicker with you guys then spending hours figuring it out. Yes, I know, time to take a class. . .but I'm loving it this new adventure!
mccarlIT Business Systems Analyst / Software DeveloperCommented:
You welcome! :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.