C# 기본 XSLTDefault.xslt

<?xml version=”1.0″ encoding=”utf-8″?>
<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”
xmlns:msxsl=”urn:schemas-microsoft-com:xslt” exclude-result-prefixes=”msxsl”>
<xsl:output method=”xml” indent=”yes”/>

<xsl:template match=”@* | node()”>
<xsl:copy>
<xsl:apply-templates select=”@* | node()”/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
______________C# sample________________


using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;

– 중간 생략 –
public XmlElement ……
{
XmlDocument docXml = new XmlDocument();
XslCompiledTransform xslt = new XslCompiledTransform();
StringWriter stringWriter = new StringWriter();

docXml = new XmlDocument();
docXml.PreserveWhitespace = false;
docXml.LoadXml(resultXML);

xslt.Load(Server.MapPath(“XSLTDefault.xslt”));
xslt.Transform(docXml, null, stringWriter);
docXml.LoadXml(stringWriter.ToString());

return docXml.DocumentElement;
}