I am using Visual Studio 2005 .NET 2.0. and C#.
Has anybody transformed xml using xsl and shown the results as a web page?
It should be a simple task.... but I can't find a way through the maze of
deprecated or incompatible classes in .NET
I have a dataset object (which has a GetXml() method which returns rows as a
xml string) that I want to transform using an xsl file. Then I want the
results in my web page. What is the best way to do this? When I copy examples
I find, I can't build because various classes are deprecated. So I replace
them with recommended alternatives and then they are incompatible.
I have tried using many different classes to do this with no success. This
is my latest attempt:
XmlDocument x = new XmlDocument();
x.LoadXml(ds.GetXml()); //ds is a Dataset object
// can't use XslTransform anymore, have to use XslCompiledTransform
XslCompiledTransform myXslTransform = new XslCompiledTransform();
myXslTransform.Load("questions.xsl");
StringWriter stringWriter = new StringWriter();
myXslTransform.Transform(x, null, stringWriter);
outputLabel.Text = stringWriter.ToString();
The ouputLabel is set to the raw xml data with the xml tags stripped and
with no transformation... not what I want. The transformation works fine when
done browser side in IE.
Rob