Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. How to ...

How to ...

Scheduled Pinned Locked Moved XML / XSL
questionxmltutorial
3 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tomas Petricek
    wrote on last edited by
    #1

    How can i transform following XML file: <data> <item name="One" /> <item name="Two" /> </data> to something like this: - One - Two ?:confused: (i do not know how to get value of name in item) Thank you

    M P 2 Replies Last reply
    0
    • T Tomas Petricek

      How can i transform following XML file: <data> <item name="One" /> <item name="Two" /> </data> to something like this: - One - Two ?:confused: (i do not know how to get value of name in item) Thank you

      M Offline
      M Offline
      Michael A Barnhart
      wrote on last edited by
      #2

      May I suggest doing a search for: XSLT value-of in google. Now the key to answer your question is the "value-of" Now what your are wanting is the value of something in an element. The first item in my search lead me to this page http://www.zvon.org/xxl/XSLTreference/W3C/xslt.html#element-value-of As it turns out it is a good staring point. Notice sample in the copy section. It uses a select statement with an '@' prior to the name they are looking for. In a select if the name is preceeded by the '@' sign it is looking for an attribute of the element that is the current focus. With out it the select would be looking for the child element of that name. A nother site to book mark is http://wdvl.com/Authoring/Tutorials/xml.html They have several introductions to XSLT that will cover this material. This http://wdvl.com/Authoring/Languages/XSL/Quickly/ is one that is on their first page now.

      1 Reply Last reply
      0
      • T Tomas Petricek

        How can i transform following XML file: <data> <item name="One" /> <item name="Two" /> </data> to something like this: - One - Two ?:confused: (i do not know how to get value of name in item) Thank you

        P Offline
        P Offline
        Philip Fitzsimons
        wrote on last edited by
        #3

        use @ to get to attributes: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">  <xsl:output method="text" encoding="iso-8859-1" indent="no" />  <xsl:template match="data">   <xsl:apply-templates select="item"/>  </xsl:template>  <xsl:template match="item">   - <xsl:value-of select="@name"/>  </xsl:template> </xsl:stylesheet>


        "When the only tool you have is a hammer, a sore thumb you will have."

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups