Skip to content

Instantly share code, notes, and snippets.

@adhamankar
Created February 2, 2015 12:53
Show Gist options
  • Save adhamankar/b8497fc85d032a2614ef to your computer and use it in GitHub Desktop.
Save adhamankar/b8497fc85d032a2614ef to your computer and use it in GitHub Desktop.
Xsl transform implementation
public static class XslUtil
{
public static string Transform(this string xml, string transformXslFile)
{
XslTransform xslt = new XslTransform();
xslt.Load(transformXslFile);
XPathDocument xpath = new XPathDocument(XmlReader.Create(new StringReader(xml)));
XmlReader xmlReader = xslt.Transform(xpath, null);
if (xmlReader != null)
{
StringBuilder sb = new StringBuilder();
while (xmlReader.Read())
sb.AppendLine(xmlReader.ReadOuterXml());
return sb.ToString();
}
return string.Empty;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment