473,387 Members | 1,463 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,387 software developers and data experts.

Get from a DataView to an XPathDocument

I want to get from a dataview to an XPathDocument.

I have tried the following:

System.IO.MemoryStream memstream = new System.IO.MemoryStream() ;
DataView.ToTable().WriteXml(memstream);

XPathDocument oXPathDocument = new XPathDocument(memstream);

My xPathDocument line crashes with the error "Root element is missing"

If I do my WriteXml to a file on disk it appears complete.

Anyone know what I need to do to get from a DataView to and xPathDocument? I
want to avoid writing anything to disk.

TIA,

Chris
Jan 30 '07 #1
3 2254
Hi Chris,

The position of stream should be set to "0", otherwise the stream will be
read from the ending.
memstream.Position = 0;

System.IO.MemoryStream memstream = new System.IO.MemoryStream() ;
DataView.ToTable().WriteXml(memstream);
memstream.Position = 0;
XPathDocument oXPathDocument = new XPathDocument(memstream);

Please test the above and let me whether or not this is what you need.

Hope this will help.
Wen Yuan

Jan 31 '07 #2
That did it.
This was a major help to me.
Thanks a lot.

Chris

""WenYuan Wang"" <v-******@online.microsoft.comwrote in message
news:aU**************@TK2MSFTNGHUB02.phx.gbl...
Hi Chris,

The position of stream should be set to "0", otherwise the stream will be
read from the ending.
memstream.Position = 0;

System.IO.MemoryStream memstream = new System.IO.MemoryStream() ;
DataView.ToTable().WriteXml(memstream);
memstream.Position = 0;
XPathDocument oXPathDocument = new XPathDocument(memstream);

Please test the above and let me whether or not this is what you need.

Hope this will help.
Wen Yuan

Jan 31 '07 #3

You are welcome, Chris.

Have a great day!
Wen Yuan

Feb 1 '07 #4

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

Similar topics

5
by: xmlguy | last post by:
I believe this should be pretty elementary, but for some reason I cannot seem to think of how to write the an XML file from an incoming XML file. Basically this is what I do: Input: ...
2
by: xmlguy | last post by:
Cant seem to solve this problem I need to be able to re-use XmlReader and XPathDocument for an XSLT Transform. Basically I have defined following interfaces: Class Render (Common and...
2
by: D | last post by:
Hi, I am trying to instantiate an instance of XPathDocument after serializing XML into a memory stream. Here is my method that uses XmlSerializer public MemoryStream...
8
by: Keith Chadwick | last post by:
My problem is this. I have to create several xmlReader objects each retrieving 'for xml' formatted sql server data. I then need to peice them together into a single document and place them into a...
2
by: Robert Strickland | last post by:
I load an xml stream into a xpathdocument type, compile a xpath expression and select to specific node. I find the node and wish to return the innerxml of that node. When I use value of the current...
2
by: steve bull | last post by:
I have an XPathDocument which contains a list of color definitions. If I want to add a new color definition to, or delete an existing one from, the source xml file how can I force this to be...
0
by: Joe Pannone | last post by:
I need a way to allow a variable to equal an xml document. When using xpathdocument the parameter is asking for a filename. Since I plan on doing a lot of search in the xml document I would like...
2
by: Tony Girgenti | last post by:
Hello. I'm developing a web comsuming client using VS.NET 2003(VB), .NET Framework 1.1.4322, ASP.NET 1.1.4322, WSE2.0 on a WinXP Pro Sp2 computer. I'm getting an XML document this way: Dim...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I've been trying to improve the performance of our xml handling, so I've been doing some timing tests lately and ran across something I thought odd - XPathDocument seems slightly slower...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...

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.