Here's the background ... When I was passing an XmlDataDocument to an
XslTransform, I was getting HORRIBLE performance.
Someone no the Xsl newsgroups suggested I pass an XPathDocument instead. The
XPathDocument constructor that made most sense was the one that took an
XmlReader in.
I got an incredible performance improvement when using the XPathDocument as
opposed to the XmlDataDocument ... All I needed was to figure out how to get
the Xml into an XmlTextReader, then cast it to an XmlReader, and use it to
create the XPathDocument
DataSet oDataSet = populate dataset with some report data
XmlTextReader oXmlTextReader = new XmlTextReader(o DataSet.GetXml( ),
XmlNodeType.Doc ument, null);
System.IO.FileS tream oFileStream = new System.IO.FileS tream(exportPat h,
System.IO.FileM ode.Create);
System.Xml.XmlT extWriter oXmlTextWriter = new
System.Xml.XmlT extWriter(oFile Stream, System.Text.Enc oding.Unicode);
try
{
XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver( );
oXmlUrlResolver .Credentials = CredentialCache .DefaultCredent ials;
System.Xml.Xsl. XslTransform oXslTransform = new
System.Xml.Xsl. XslTransform();
oXslTransform.L oad(_XslPath, oXmlUrlResolver );
XPathDocument oXPathDocument = new XPathDocument(o XmlReader);
oXslTransform.T ransform(oXPath Document, null, oXmlTextWriter,
oXmlUrlResolver );
oXmlTextWriter. Close();
return exportPath; // path of exported file
}
catch (Exception ex)
{
oXmlTextWriter. Close();
System.IO.File. Delete(exportPa th);
throw(ex);
}
"Patrick Steele [MVP]" <pa*****@mvps.o rg> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
In article <eU************ **@TK2MSFTNGP10 .phx.gbl>, gd****@hotmail. com
says... Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I
do that?
Why do you need to do this? DataSet.WriteXm l can convert the DataSet
into an XML format and then the Reader can read the XML. But if you
just want the data from the DataSet, why serialize it to XML?
--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele