I want to transform a XML document, but having a problem.
My XSLT looks like this:
I solved it. Actually "XslCompiledTransform.Transform" takes XmlReader as first Parameter and i was passing XmlDocument in First Paramenter. Here is the code.
public static string Transform(XmlDocument doc, XmlDocument stylesheet)
{
try
{
System.Xml.Xsl.XslCompiledTransform transform = new System.Xml.Xsl.XslCompiledTransform();
transform.Load(stylesheet); // compiled stylesheet
System.IO.StringWriter writer = new System.IO.StringWriter();
XmlReader xmlReadB = new XmlTextReader(new StringReader(doc.DocumentElement.OuterXml));
transform.Transform(xmlReadB, null, writer);
return writer.ToString();
}
catch (Exception ex)
{
throw ex;
}
}