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

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(curDir + "\\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 3677
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**************@TK2MSFTNGP14.phx.gbl...
Hi,

I use the ReadXML method in my C# Windows Form project.
Here is some of my C# code:
xmlDS.ReadXml(curDir + "\\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**************@TK2MSFTNGP14.phx.gbl...
Hi,

I use the ReadXML method in my C# Windows Form project.
Here is some of my C# code:
xmlDS.ReadXml(curDir + "\\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
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...
3
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...
0
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...
0
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 >= '"...
2
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
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...
7
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...
5
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...
3
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...
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?
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
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...
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...
0
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...
0
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...

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.