I'm learning how to use the XSL transform functionality and can't get
it to work. In a book I'm reading on it, it says that I can do like I
did below and just add a value like <root_node/> in there and I should
be able to transform any XML source document I have so that the
results would simply contain <root_node/>.
I wanted to try that, just so I could see if I understand how this is
working and wrote the code and XSL file below. However, my value for
szTransformedXML is always an empty string. Does anyone see what I'm
doing wrong?
Here's a method I wrote to use it:
private void TransformData(string szXML, out string szTransformedXML)
{
XslTransform oXsl = new XslTransform();
XmlDocument oXMLDoc = new XmlDocument();
oXsl.Load(@"C:\\Srclib\\Test.xsl");
oXMLDoc.LoadXml(szXML);
XmlReader oRead = oXsl.Transform(oXMLDoc.CreateNavigator(),null);
oXMLDoc = null;
szTransformedXML = oRead.ReadOuterXml();
}
Here's what my Test.xsl file looks like:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<root_node/>
</xsl:template>
</xsl:stylesheet>