473,805 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

filtering an XML Dataset

Hi,

I use the ReadXML method in my C# Windows Form project.
Here is some of my C# code:
xmlDS.ReadXml(c urDir + "\\Dept.xml ") ;

There're 20 rows and 5 columns in the Dept.xml.
But now I just want some of the data in the Dept.xml, e.g., DeptLevel >1 AND
Status=0.
How do I filter the XML or xmlDS so that the output is what I need?
Thanks for help.
Jason
Mar 30 '06 #1
2 3712
You need to understand DataSets better, and the difference between a
serialized class and the class itself. The XML file you're talking about is
an XML document. When you create a DataSet and read from the file to
populate it, you are no longer dealing with XML; you're dealing with a
DataSet. An XML document doesn't have columns and rows; it has nodes. A
DataSet doesn't have columns and rows either; it has Tables (DataTables) and
schema information about the data and the tables. A DataTable can not be
filtered. But when you use a DataTable, you generally work with a DataView
rather then the table itself. Now, a DataView can be filtered, sorted, and
manipulated in a variety of ways. For more information, see:

http://msdn.microsoft.com/library/de...xmldataset.asp
http://msdn.microsoft.com/library/de...ngdatasets.asp
http://msdn.microsoft.com/library/en...asp?frame=true
http://msdn.microsoft.com/library/en...asp?frame=true

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Jason Huang" <Ja************ @hotmail.com> wrote in message
news:u9******** ******@TK2MSFTN GP14.phx.gbl...
Hi,

I use the ReadXML method in my C# Windows Form project.
Here is some of my C# code:
xmlDS.ReadXml(c urDir + "\\Dept.xml ") ;

There're 20 rows and 5 columns in the Dept.xml.
But now I just want some of the data in the Dept.xml, e.g., DeptLevel >1
AND Status=0.
How do I filter the XML or xmlDS so that the output is what I need?
Thanks for help.
Jason

Mar 30 '06 #2

"Jason Huang" <Ja************ @hotmail.com> wrote in message
news:u9******** ******@TK2MSFTN GP14.phx.gbl...
Hi,

I use the ReadXML method in my C# Windows Form project.
Here is some of my C# code:
xmlDS.ReadXml(c urDir + "\\Dept.xml ") ;

There're 20 rows and 5 columns in the Dept.xml.
But now I just want some of the data in the Dept.xml, e.g., DeptLevel >1
AND Status=0.
How do I filter the XML or xmlDS so that the output is what I need?
Thanks for help.


Your best bet is probably just to use a DataView.

If you really want to filter the data coming into the dataset then either

use a DataView to do the filtering and copy it into another dataset

OR create your own class derived from XmlReader to do the filtering and pass
it to the overload of ReadXml. This reader should be quite simple as it just
has to filter the output of an XmlTextReader which will actually read the
file.
Mar 30 '06 #3

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

Similar topics

3
3158
by: Alex Ayzin | last post by:
Hi, I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go: I have a dataset with 2 datatables in it. Now, I need to do the following: if ds.table(0).rows(0).item("col1") = ds.table(1).rows(0).item("col2") then txtResult.text = ds.table(1).rows(0).item("col3")
3
2199
by: serge calderara | last post by:
Dear all, I have a csv file data which has been read and populate on a dataset object. then I need to bind part of the content of the dataset to a treeview control. I have read that XML format is particular usefull to be bind to a treeview as it handle nodes. So I have try to save my dataset content into a xml file. The content of that file is as follow : - <NewDataSet> - <REC_INFO>
0
3650
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
0
1186
by: Jenny C. | last post by:
Hi I am trying to do a SUM on a DataSet column with the following code // ds is the DataSet that I need to calculate data fro String filter2 = "EmpNo = " + this.EmpNo + " AND WEEK_ENDING >= '" + MyDateTime.Date.ToShortDateString() + "'" float totalGross = Convert.ToSingle(this.ds.Tables.Compute("SUM(GROSS)", filter2)) float totalEarn = Convert.ToSingle(this.ds.Tables.Compute("SUM(Earns)", filter2)) Here the problem: it doesn't...
2
3996
by: Marco Ippolito | last post by:
I have an offline DataSet: id (PK, sorted ASC), firstname, enabled 1, Aaron, true 2, Bill, false 3, Charlie, true .... 10001, Mike, false 10002, Nathan, false
0
1594
by: ber.janssens | last post by:
Hi, I am trying the new ObjectDataSource from ASP.NET 2.0. I connected a Gridview with ObjectDataSource which is connected to a webservice which returns a DataSet. In the Webmethod I return only the rows for the current page because paging is enabled, I use the parameters maximumRows and startRowIndex for doing this. I also got sorting to work using the parameter sortExpression. The method of the webservice looks like this:
7
14823
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1 but how is this done now in asp.net 2.0?
5
1910
by: LDD | last post by:
Hi Folks I'm trying to determine a way to handle paging, filtering and sorting in a datagrid. If I choose to filter and sort, I'd like to return a subset. If that resultset has more records then the number of rows I'd like to display, I'd like to be able to load pages into the grid. My question is, do I need to continually hit the db to get the next page of records, or is there another method of doing with the dataset. i.e. load the
3
1868
by: Shawn Ramirez | last post by:
As with most web applications speed is a huge deal to me in my applications. My customers don't really care if my app is a true 3 tier application or not, they just want it to be faster then it was yesterday. Because of this I try to limit my calls to the database by using a loading lookup data for a customer and then filtering down to what I need. (I have alot of recursive logic because of alot of tree controls). Here is my question. ...
0
10617
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
10364
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...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4328
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3849
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.