473,651 Members | 3,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3058
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******** ******@TK2MSFTN GP10.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(o DataSet.GetXml( ),
XmlNodeType.Doc ument, null);
"Kevin Spencer" <ke***@takempis .com> wrote in message
news:ew******** ******@TK2MSFTN GP10.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******** ******@TK2MSFTN GP10.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.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
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(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

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
2266
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 source to bind xmldoc to datagrid control.
1
3580
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 made: public readonly DataSet Schema; Schema = new DataSet(); Schema.ReadXmlSchema(this.SchemaFile); Following exception is returned:
4
1302
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
3627
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 xsd:restriction conditions are ingested without a murmur. Is this a bug or a feature? Very frustrating. Evidence: 1) XML data <?xml version="1.0" encoding="utf-8"?>
2
4689
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 tables in one call. I'm using Microsoft EnterpriseLibrary for Data to get the data from SP. It works fine and I get two tables in the dataset, "Table1" and "Table2". I then have an XML-file, which will serve as a template to generate the XML-schema,...
8
2913
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 have is if one can determine the node depth as they import the XML. I could, obviously, just put the node depth in as another xml element at the time of creation, which really isn't a big deal, but thought I'd see if I could do it on the import...
1
3820
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 the exception ONLY in Web Sites:
7
3361
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 depending on peak access. I have built an XML file from SQL DB and pushed this file to web server. I want to load XML file at application startup and leave it cached if possible (it will vary in size from 1-2MB) and treat it like an SQL table...
1
4141
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 dataseta in XmlNode ... http://www.alvas.net - Audio tools for C# and VB.Net developers
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8278
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.