Lucas
Lucas

Reputation: 10646

Using C# to display an XML file transformed by XSLT

I don't know if this is possible or if I am thinking about this in the wrong way, but this is what I want to do:

I have an XML file linked to an XSLT file and I want to use C# to get the output of the transformed XML file and Response.Write() that wherever I want on the page.

I have found questions on stackoverflow about saving the transformed output to a new file etc, but I don't want to save it to a file, I just want to display it with Response.Write() anywhere on my aspx page.

Is there any way to do this in C#?

Any help is appreciated.

Upvotes: 2

Views: 954

Answers (4)

Tom Squires
Tom Squires

Reputation: 9286

Yes, save the transformed file to a MemoryStream (so in memory not the hard disk). You can then output that to a string using a filestrem reader.

Upvotes: 2

Steve Morgan
Steve Morgan

Reputation: 13091

You could save yourself the effort and simply serve up the XML to the browser. As long as the XML document references the URL of the corresponding XSLT document, the browser will render the page for you.

Upvotes: 1

Henk Holterman
Henk Holterman

Reputation: 273264

Another way of doing it is by using the XML control, it has XML and XSLT properties.

Upvotes: 2

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56162

Use HttpResponse.OutputStream as output stream to save transformed file.

Upvotes: 0

Related Questions