473,378 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

DataSet into XmlReader

Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I do
that?
Thanks!
Nov 18 '05 #1
5 3041
My head hurts from trying to figure how how one could write to a reader...

Happy New Year, everyone!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"George Durzi" <gd****@hotmail.com> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I do that?
Thanks!

Nov 18 '05 #2
I guess I used some wrong terminology. I guess if the reader is "reading",
something is writing to it ... hahah

DataSet oDataSet = Some Report Data
XmlTextReader oXmlTextReader = new XmlTextReader(oDataSet.GetXml(),
XmlNodeType.Document, null);
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
My head hurts from trying to figure how how one could write to a reader...

Happy New Year, everyone!

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"George Durzi" <gd****@hotmail.com> wrote in message
news:eU**************@TK2MSFTNGP10.phx.gbl...
Folks, I'd like to write out a DataSet's Xml into an XmlReader? How do I

do
that?
Thanks!


Nov 18 '05 #3
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.WriteXml 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
Nov 18 '05 #4
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(oDataSet.GetXml(),
XmlNodeType.Document, null);
System.IO.FileStream oFileStream = new System.IO.FileStream(exportPath,
System.IO.FileMode.Create);
System.Xml.XmlTextWriter oXmlTextWriter = new
System.Xml.XmlTextWriter(oFileStream, System.Text.Encoding.Unicode);
try
{
XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver();
oXmlUrlResolver.Credentials = CredentialCache.DefaultCredentials;
System.Xml.Xsl.XslTransform oXslTransform = new
System.Xml.Xsl.XslTransform();
oXslTransform.Load(_XslPath, oXmlUrlResolver);
XPathDocument oXPathDocument = new XPathDocument(oXmlReader);
oXslTransform.Transform(oXPathDocument, null, oXmlTextWriter,
oXmlUrlResolver);
oXmlTextWriter.Close();

return exportPath; // path of exported file
}
catch (Exception ex)
{
oXmlTextWriter.Close();
System.IO.File.Delete(exportPath);
throw(ex);
}


"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
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.WriteXml 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

Nov 18 '05 #5
In article <es**************@tk2msftngp13.phx.gbl>, gd****@hotmail.com
says...
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


An XmlTextReader is an XmlReader, so no casting should be necessary.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
I'd like to load xml contents to my dataset from an XML document in memory. The dataset.ReadXML requires a file on drive. Is there a way to do this from xmldoc in memory? Goal is to use data...
1
by: Tarun Upadhyay | last post by:
I am trying to read the standard UDDI schema using a DataSet. however, it always chokes with error. Here are the full details: Schema used: http://uddi.org/schema/uddi_v3.xsd C# (.NET) calls...
4
by: Shapper | last post by:
Hello, I have a XML file that includes the node <item>: .... <title>...</title> <url>...</url> <item> <title>title 01</title> <description>description 01</description> </item>
1
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify...
2
by: Henrik | last post by:
Hi, I'm really stuck with this one. I have a dataset with two tables. One table is company data, and the other is contacts. I populate these by using a SP in SQL Server which returns the two...
8
by: darrel | last post by:
I've decided that instead of doing an XSLT transformation on a file, I might be better off bringing it in as a dataset and having a bit more direct control over it at that point. The question I...
1
by: Angel \Java\ Lopez | last post by:
Hi people! I'm running a Visual Studio 2005, Professional, on Windows XP Professional. I've found a little big problem, reading a DataSet. If I try: ds.ReadXml("c:\data.xml") it raises...
7
by: =?Utf-8?B?ZG91Zw==?= | last post by:
Have loaded balanced web servers that we do not allow to connect to our database. Content is created and pushed to these sites. I want to add a web service that may get multiple requests a second...
1
by: Alexander Vasilevsky | last post by:
Is that valid XmlNode for dataset xml. How to fill in those xml 'of a dataset? There DataSet.ReadXml (XmlReader), but you can initialize XmlReader only URI xml- file, and I have a xml data...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.