473,545 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Querying a dataset filled from XML file

I have a simple application that uses an XML file to store it's data. That
means I don't have a seperate database. In order to read the data I created a
DataSet that reads my XML file with the .ReadXml() method.

1.
I want to manipulate the resulting dataset, preferably with SQL queries. But
the documentation states that I need to have a data connection to do this.
But if I am only using an XML file, how do I do this without a data
connection?

2.
When I fill the dataset I have no trouble reading the column names, but how
do I read the attributes? For instance, this is a portion of my XML file:

<partyList xmlns="http://tempuri.org/DataSchema.xsd" >
<party xmlns="http://tempuri.org/DataSchema.xsd" >
<Name>CDA</Name>
<Leader>
<Name>J.P. Balkenende</Name>
</Leader>
</Name>
</party>
</partyList>

To read the Party Name I use dsParties.Table s("Party").Rows (0).Item("Name" ),
but how do I access the Leader Name ?

Any help on these 2 questions would be appreciated!
-Chris
Nov 12 '05 #1
3 2291
"C. Hughes" <C. Hu****@discussi ons.microsoft.c om> schrieb
1.
I want to manipulate the resulting dataset, preferably with SQL queries. But the documentation states that I need to have a data connection to do this.
But if I am only using an XML file, how do I do this without a data
connection?
you can't modify a DataSet with SQL queries. You can only fill it by an
SqlCommand or DataAdapter which uses SQL queries and a data connection to
get data from a database.
If you want to filter the data of a DataSet, you can use DataViews.

2.
When I fill the dataset I have no trouble reading the column names, but how do I read the attributes? For instance, this is a portion of my XML file:

<partyList xmlns="http://tempuri.org/DataSchema.xsd" >
<party>
<Name>CDA</Name>
<Leader>
<Name>J.P. Balkenende</Name>
</Leader>
</Name>
</party>
</partyList>

To read the Party Name I use dsParties.Table s("Party").Rows (0).Item("Name" ), but how do I access the Leader Name ?


dsParties.Table s("Leader").Row s(0).Item("Name ")
(Remark: Leader is not an attribut, it is an element)

Or if you have set the DataRelation between the Tables "Party" and "Leader"
(in C#):
dsParties.Table s["Party"].Rows[0].GetChildRows(r elationPartyLea der)[0]["Name
"]

Roughly: Elements (with complex type) will be readed as a table, and
Attributes (and Elements with simple type) as columns to the Element-tables.

Jaga

Nov 12 '05 #2
Hi Jaga,

Thanks for your reply. It has helped me, but there is one thing is still
don't understand.

If in my previous example "Leader" is loaded as a seperate table to "Party",
then how do I maintain a relation between these two? If I were to extend the
XML file so that each Party could have N number of leaders then how do i
still know which leader belongs to which party ?
Nov 12 '05 #3
"C. Hughes" <CH*****@discus sions.microsoft .com> wrote
If in my previous example "Leader" is loaded as a seperate table to "Party", then how do I maintain a relation between these two? If I were to extend the XML file so that each Party could have N number of leaders then how do i
still know which leader belongs to which party ?


Both tables ("Party" and "Leader") receives a column "Party_Id" with the
attribute ColumnMapping=H idden.
Each Party receives an unique Party_Id and each Leader receives the Party_Id
of his Party.
The DataSet receives a DataRelation "Party_Lead er" between the columns
Party.Party_Id and Leader.Party_Id .

Jaga

Nov 12 '05 #4

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

Similar topics

5
1939
by: Sadun Sevingen | last post by:
hi i get dataset from'an webservice so i don't have an adaptor... dataset's structure is same as mine database table.... how can i update database table according to dataset...
1
3582
by: Johann Blake | last post by:
I have a dataset that contains a parent table and a child table. A DataRelation exists between the two. I was under the impression from reading the VS docs that when I filled the parent table, the child table would be automatically filled with the child records. When I fill the parent, I limit the table to only a single record, so that all the...
3
1573
by: MDB | last post by:
I'd normally Google for a question like this, and hope to snag a few examples along with the answer, but this time I can't see to get the keywords specific enough. Or I'd ask coworkers, but they're just as new to ASP.NET as I am. Is it possible to have a dataset filled with all the records in an SQL table (on the small side, maybe three...
1
1047
by: Adam Knight | last post by:
Hi all, A couple of quick questions relating to datasets: Is one dataset in a given page generally used to bind all controls to db data? If a dataset object is to be used globally by all, is it best to use the 'New DataSet' declaration in PAGE_LOAD?
2
1824
by: Jeff Brown | last post by:
OK i have came to the conclusion that since this app will be run on multiple computers that loading a complete database and then updating on exit is a moot point. I have tried several ideas submitted, but i am unable to get one of them to work completely. Here is the code i had before i realized that when i filled the dataset in the form load...
3
2982
by: filip.norrgard | last post by:
Hi All! I've been developing an ASP.Net 2.0 web application using the Visual Studio 2005 tools. Currently datagrids on a page are filled with data from a dataset (a .xsd file in the "project") that, in turn, gets the data from MySql server. Locally testing it on my PC (Windows XP SP2, FYI) it works and no errors appear. However, when I...
5
3680
by: sql_er | last post by:
Guys, I have an XML file which is 233MB in size. It was created by loading 6 tables from an sql server database into a dataset object and then writing out the contents from this dataset into an XML file. Once my application starts, I load this XML file into a DataSet object using "ReadXML" function. This creates a dataset in memory with...
2
1112
by: darrel | last post by:
We have a home grown web site. We store page information, including a time-stamp as to when it was last updated in a database table. We also store the site architecture (navigation) in an XML file. We want to create RSS feeds that show the most recent page updates for a particular node of our site menu. For instance, HR might want an RSS...
4
1197
by: Andy B | last post by:
I have a wizard on a page that will dynamically create a dataset as it goes along based on user input. When the wizard is done, it will dump all of the data it collected/created in the wizard to an xml file. Should this be an in memory version or a dataset or a file based dataset?
0
7416
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7676
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. ...
0
7932
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...
1
7442
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7776
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...
0
4965
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...
0
3456
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1905
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
0
729
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...

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.