Using XML Stream with XSL Transform

F

Fritz Switzer

I'm using an XML file with the code snippet below to create a html page.
However, my xml is stored in a database and I'd like to pull out the data as
a string and convert it to a stream rather than use an xml file. But I
can't figure out how...any help would be appreciated.

XslTransform xslt = new XslTransform();

xslt.Load("Books.xsl");

xslt.Transform("Books.xml", "Books.html");

browser.Navigate(@"Books.html");


TIA,

Fritz
 
A

Aboulfazl Hadi

Hi Fritz,
So You have a stream of string and you want to use in XslTransform.
You can use the others overloading of Transform method. One of them get
an XMLNavigator


// Get xml from database

// Convert it to stream

XslTransform xslt = new XslTransform();
XmlDocument doc=new XmlDocument();
doc.Load(yourStream);

xslt.Transform(doc.CreateNavigator(), new
XsltArgumentList(),outputStream);

// Convert outputStreaem to the file or use Webbrowser.DocumentStream (
if you use .Net ver 2.0 )

meanwhile, the XsltTransform is now obsolete in .Net Framework 2.0

I hope it helps you
A.Hadi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top