473,903 Members | 3,835 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 2303
"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
1955
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
3612
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 records in the child table will belong to this parent. But when the Fill method is executed with...
3
1586
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 hundred records total), and then query that table for subsets of data, e.q. a simple WHERE clause,...
1
1067
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
1841
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 procedure that it would "ruin, replace, mess up" the dataset named the same thing on the other form....
3
3002
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 upload it to the webserver (Windows 2003 Web Edit. Server) I get the a parser error on the dataset...
5
3691
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 6 tables.
2
1124
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 feed to list all recent HR page updates. To do this, we need to get the HR page, all childrend of...
4
1211
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
10004
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9853
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11293
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...
1
10989
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10504
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
9692
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...
1
8057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5899
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3327
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.