Created
February 2, 2015 12:53
-
-
Save adhamankar/b8497fc85d032a2614ef to your computer and use it in GitHub Desktop.
Xsl transform implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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