dataset and xslt



Hi there,

I want to create flat txt file from my data stored in my dataset.
I do xslt transformation and i've got sth like that:
(where ds - is my dataset, output.txt - is my result

//Create a new XslTransform object.
XslTransform xslt = new XslTransform();

//Load the stylesheet.
xslt.Load(Application.StartupPath + @"\Temp\xsltFile.xsl");

//Create a new XPathDocument and load the XML data to be transformed.
ds.WriteXml(Application.StartupPath + @"\Temp\officedata.xml");
XPathDocument mydata = new XPathDocument(Application.StartupPath +

//Create an XmlTextWriter
XmlWriter writer = new XmlTextWriter(Application.StartupPath +
@"\Outbox\output.txt" , System.Text.Encoding.ASCII);

//Transform the data.
xslt.Transform(mydata,null,writer, null);


How do the same thing without creating temp file officedata.xml?
(create XpathDocument directly from ds.)

and how load xslt file from string instead of xsltFile.xsl?

Does anyone have an idea?

Many thanks,



Hello Kamil,

To fill the XPathDocument directly from the DataSet you can do
something like...

DataSet ds = new DataSet();
Code to fill ds
StringReader sr = new StringReader(ds.GetXml());
XPathDocument doc = new XPathDocument(sr);

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

Similar Threads

xslt and .net 1
xml + xslt convert to rtf problem 2
Problem with MemoryStream 2
newbie: XSL transform and include 1
Dataset Transformed to Word via XML 6
xml & xsl transform 1
Is this thread safe? 24