public static XmlElement Transfomer(string xsltFilePath, XmlDocument bericht)
{
XslCompiledTransform transformer = new XslCompiledTransform();
XsltSettings xsltSettings = new XsltSettings(false, true);
transformer.Load(xsltFilePath, xsltSettings, new XmlUrlResolver());
XmlDocument transformedMessage = new XmlDocument();
using (MemoryStream memoryStream = new MemoryStream())
{
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.Indent = true;
writerSettings.IndentChars = "\t";
writerSettings.Encoding = System.Text.Encoding.UTF8;
writerSettings.ConformanceLevel = ConformanceLevel.Fragment;
writerSettings.OmitXmlDeclaration = true;
XmlWriter writer = XmlWriter.Create(memoryStream, writerSettings);
transformer.Transform(bericht, writer);
writer.Flush();
memoryStream.Position = 0;
transformedMessage.Load(memoryStream);
}
return transformedMessage.DocumentElement;
}
{
XslCompiledTransform transformer = new XslCompiledTransform();
XsltSettings xsltSettings = new XsltSettings(false, true);
transformer.Load(xsltFilePath, xsltSettings, new XmlUrlResolver());
XmlDocument transformedMessage = new XmlDocument();
using (MemoryStream memoryStream = new MemoryStream())
{
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.Indent = true;
writerSettings.IndentChars = "\t";
writerSettings.Encoding = System.Text.Encoding.UTF8;
writerSettings.ConformanceLevel = ConformanceLevel.Fragment;
writerSettings.OmitXmlDeclaration = true;
XmlWriter writer = XmlWriter.Create(memoryStream, writerSettings);
transformer.Transform(bericht, writer);
writer.Flush();
memoryStream.Position = 0;
transformedMessage.Load(memoryStream);
}
return transformedMessage.DocumentElement;
}
No comments:
Post a Comment