I'm calling a C# function from XSLT in Umbraco 4.7.1. My function is returning value of the "tag" property on current node, problem is my output is encoded.
In xsltExtensions.config I have added an assembly extension.
In my XSLT I'm getting the value of my function
<xsl:value-of select="TagHelpers:ShowAllTags()" />
My C# function:
public string ShowAllTags()
{
var node = new DynamicNode(Node.GetCurrent());
var html = new StringBuilder();
if (node.HasProperty("tags"))
{
var tagList = node.GetPropertyValue("tags");
if(tagList.Length > 0)
{
foreach (var tag in tagList)
{
html.Append(HttpUtility.HtmlEncode(tag));
}
}
}
return html.ToString();
My output looks like:
%3c%3fxml+version%3d%221.0%22%3f%3e%0d%0a%3cClientValue+xmlns%3axsd%3d%22http%3a%2f%2fwww.w3.org%2f2001%2fXMLSchema%22+xmlns%3axsi%3d%22http%3a%2f%2fwww.w3.org%2f2001%2fXMLSchema-instance%22%3e%0d%0a++%3cTags%3e%0d%0a++++%3cstring%3efritidsjob%3c%2fstring%3e%0d%0a++++%3cstring%3elo%3c%2fstring%3e%0d%0a++++%3cstring%3ejobpatrulje%3c%2fstring%3e%0d%0a++%3c%2fTags%3e%0d%0a++%3cGroupName%3edefault%3c%2fGroupName%3e%0d%0a%3c%2fClientValue%3e
But should be:
fritidsjob, jobpatrulje, lo
You can get rid of the encoding by adding disable-output-encoding="yes" to your xslt select, e.g.
<xsl:value-of select="TagHelpers:ShowAllTags()" disable-output-encoding="yes" />
However, it looks like your tags are being stored as XML, rather than a comma separated string. Which tag control are you using?