'XSTL Transform file to XML with C#
I have to add a specific element/node for the xsl stylesheet using c# code. This is the following code that I have to add that new lines:
AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
var xsltransf = new XslCompiledTransform();
var xmlMemoryDoc = new XmlDocument();
xmlMemoryDoc.Load(new StringReader(XElement.Load(@"D:\PRJ\SPM.861\SEE PM - WEB SERVICE\3.08.1.5\Default\Env\ContentVisualisations\WD\Diagram_Content_HTML_WD_View_HierarchicalCables (1).XSLT").ToString()));
var xmlFileDoc = new XmlDocument();
xmlFileDoc.Load(@"D:\PRJ\SPM.861\SEE PM - WEB SERVICE\3.08.1.5\Default\Env\ContentVisualisations\WD\Diagram_Content_HTML_WD_View_HierarchicalCables (1).XSLT");
xsltransf.Load(xmlFileDoc, new XsltSettings { EnableDocumentFunction = true }, new XmlUrlResolver());
var contentXPathDoc = new XPathDocument(XmlReader.Create(new StringReader(XElement.Load(@"D:\PRJ\SPM.861\SEE PM - WEB SERVICE\3.08.1.5\Default\Env\ContentVisualisations\WD\WD.xml").ToString())));
var writer = new StringWriter();
// File.WriteAllText(@"D:\PRJ\SPM.861\result.html", writer.ToString());
xsltransf.Transform(contentXPathDoc.CreateNavigator(), null, writer/*, @"D:\Prj\SPM\8.50\1\SEE PM - WEB SERVICE\3.07.1.7\Default\Env\ContentVisualisations\WD\out.html"*/);
var sr = writer.ToString();
and "document" is the element that I have to add (in the original xslt there is not "document" element):

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
