Solved

XPathDocument result to DataSource

Posted on 2003-11-06
1
251 Views
Last Modified: 2012-08-14
Hi,

I use an XPathDocument class for filter any Xml data. I using the XPathNavigator, XPathNodeIterator too.
How can I transfer the selected result to a DataSource?
Currently I write a temporaly Xml file and read it into a DataSource, this is not a brilliant way. :-(

Have anyboody got other best idea?

Thank you,
0
Comment
Question by:stonecastle
1 Comment
 
LVL 9

Accepted Solution

by:
_ys_ earned 100 total points
ID: 9694128
Try using the XmlDataDocument class, instead of the XPathDocument class. (System.Xml namespace)

It supports XPathNavigator etc. But it also supports IEnumerable, and can therefore be used directly as a DataSource.


//Create an XmlDataDocument.
XmlDataDocument doc = new XmlDataDocument();

//Load the schema file.
doc.DataSet.ReadXmlSchema("source.xml");

//Load the XML data.
doc.Load("source.xml");


ReadXmlSchema and Load have overloaded declarations. Whatever means you're using currently to populate your XPathDocument will no doubt be reusable here.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now