How to ...
-
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 -
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 youMay 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.
-
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 youuse @ 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."