Solved

XPathDocument result to DataSource

Posted on 2003-11-06
1
254 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

17 Experts available now in Live!

Get 1:1 Help Now