Created
February 24, 2014 12:17
-
-
Save stevecooperorg/9187337 to your computer and use it in GitHub Desktop.
XsltTools
This file contains 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
namespace XmlStuff | |
{ | |
using System.IO; | |
using System.Text; | |
using System.Xml; | |
using System.Xml.Xsl; | |
internal class XsltTools | |
{ | |
public string Transform(string xsltContent, string inputXml) | |
{ | |
var xslt = new XslTransform(); | |
using(var textReader = new StringReader(xsltContent)) | |
using(var reader = XmlReader.Create(textReader)) | |
{ | |
xslt.Load(reader); | |
} | |
XmlDocument inputXmlDoc =new XmlDocument(); | |
inputXmlDoc.LoadXml(inputXml); | |
var outputSb = new StringBuilder(); | |
using (var textWrite = new StringWriter(outputSb)) | |
{ | |
xslt.Transform(inputXmlDoc, new XsltArgumentList(), textWrite); | |
} | |
return outputSb.ToString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment