I need to output some related data tables as XML. I have my data adapters
and my dataset with the relations defined. It is certainly simple enough to
use the dataset.WriteXM L function. However, this writes the data such that
each
DataTable in the dataset is written one after the other. This is not what I
need. I do not need to be able to load this back into a dataset at a later
time. The XML file and schema I generate will be used to import the data
into another, completely unrelated, system.
Here is a simple example:
Tablename: Customer
Fields: CustomerID
CustomerName
Tablename: Purchases
Fields: CustomerID
PurchaseDate
PurchaseAmount
Relation: A Customer can have many Purchases (one to many)
When I save my dataset to XML it looks something like this:
<Customer>
<CustomerID>1 </CustomerID>
<CustomerName>J ohn Doe</CustomerName>
</Customer>
<Customer>
<CustomerID>2 </CustomerID>
<CustomerName>B ob Smith</CustomerName>
</Customer>
<Customer>
<CustomerID>3 </CustomerID>
<CustomerName>J ane Somebody</CustomerName>
</Customer>
<Purchases>
<CustomerID>1 </CustomerID>
<PurchaseDate >2/1/2005</PurchaseDate>
<PurchaseAmount >23.00</PurchaseAmount>
</Purchases>
<Purchases>
<CustomerID>1 </CustomerID>
<PurchaseDate >2/5/2005</PurchaseDate>
<PurchaseAmount >123.00</PurchaseAmount>
</Purchases>
<Purchases>
<CustomerID>2 </CustomerID>
<PurchaseDate >1/23/2005</PurchaseDate>
<PurchaseAmount >1.00</PurchaseAmount>
</Purchases>
I would like it to look something like below:
<Customer>
<CustomerID>1 </CustomerID>
<CustomerName>J ohn Doe</CustomerName>
<Purchases>
<PurchaseDate >2/1/2005</PurchaseDate>
<PurchaseAmount >23.00</PurchaseAmount>
</Purchases>
<Purchases>
<PurchaseDate >2/5/2005</PurchaseDate>
<PurchaseAmount >123.00</PurchaseAmount>
</Purchases>
</Customer>
<Customer>
<CustomerID>2 </CustomerID>
<CustomerName>B ob Smith</CustomerName>
<Purchases>
<PurchaseDate >1/23/2005</PurchaseDate>
<PurchaseAmount >1.00</PurchaseAmount>
</Purchases>
</Customer>
<Customer>
<CustomerID>3 </CustomerID>
<CustomerName>J ane Somebody</CustomerName>
</Customer>
Can someplease point me in the right direction how to do this (short of
manually building the XML line by line). I have tried for several hours but
feel I am missing something.
Thank in advance,
Lance 7 1682
LeRoy,
The only time I succeeded in that was when I used the designer to create
this.
I thought it was something as creating two datatables using the designer.
Than set the parentchild relation, and than drag the child over the parent.
However I never looked at the created code.
Can you try it yourself?
Cor
Still no luck. I did as you suggested but the XML saved to file still
separates the 2 datatables (the purchases are at the end of the file instead
of embedded in the customers).
Any other ideas from anyone?
Thanks,
Lance
"Cor Ligthert" wrote: LeRoy,
The only time I succeeded in that was when I used the designer to create this.
I thought it was something as creating two datatables using the designer. Than set the parentchild relation, and than drag the child over the parent.
However I never looked at the created code.
Can you try it yourself?
Cor
Thanks, but that describes how to make the schema nested. My schema is
nested. However, when I use the dataset.WriteXM L the XML produced does not
nest the data.
Lance
"Cor Ligthert" wrote: LeRoy,
This is the page and I know it works, (I tried it a while ago)
(the keyword is nested)
http://msdn.microsoft.com/library/de...xmlschemas.asp
I hope this helps?
Cor
Lance, Thanks, but that describes how to make the schema nested. My schema is nested. However, when I use the dataset.WriteXM L the XML produced does not nest the data.
This is in the sample on the page I showed you,
\\\
<Customers>
<CustomerID>ANA TR</CustomerID>
<CompanyName>An a Trujillo Emparedados y helados</CompanyName>
<Orders>
<OrderID>1030 8</OrderID>
<OrderDate>19 96-09-18</OrderDate>
<OrderDetails >
<OrderWeight>20 kg</OrderWeight>
<ShipVia>Intern ational Air</ShipVia> </OrderDetails>
</Orders>
</Customers
///
What is this different from the XML file (beside the tagnames and variables)
as the one you showed as sample in your question.
Cor
You are quite right. That does match the structure of the XML I desire.
However I am still unable to achieve the desired output for some reason.
1. My schema is nested.
2. I use 2 DataAdapters to fill the 2 data tables in the dataset (whose
schema is nested).
3. I call dataset.WriteXM L method. The resulting XML is not nested. It
lists all the records in the first table followed by all the records in the
second table (not nested).
I am probably just missing something here but it is driving me crazy trying
to figure this out :-) Any ideas?
Thanks,
Lance
I got it! There is a property on the relation called IsNested. That, of
course, must be set to true.
Thanks,
Lance This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert Muchacki |
last post by:
Hello all!
I'm fighting with this little problem. I'm trying to retrieve data from a
table in SQL Server 2k. I'm dead. The only result I get is retrieving the
headers of the columns - no data in it actually :/ I'm probably missing
something on the way. Could somebody explain me how do I get data and even
WHERE I should retrieve it to?...
|
by: Jim H |
last post by:
I'm new to gui programming. I'm just doing some testing with forms. I've
dropped a com control on a form. When a user clicks and holds the mouse
down on the control I'd like to drag the form around with the mouse. How
would I do this? Even is it were a simple control like a label or panel,
how would I do this?
I guess it comes down to...
|
by: jm |
last post by:
Easy probably, please read on. I know some of you have commented
already about some of my socket question. I appreciate that.
I have a Form1:
static void Main()
{
Application.Run(new Form1());
clsListening.AsynchronousSocketListener.StartListening();
|
by: Tomas Machala |
last post by:
Hi, I'm trying to make an application communicating over TCP/IP. It should do only one thing - write received data to console and terminate itself when "exit" received. Problem is that if I send some string to this application, it'll receive that string and many unwanted "new line" characters on its end.
Examle:
If I send
"some_string"
...
|
by: Ron |
last post by:
I want to add radio buttons to a datagrid. The datagrid is displaying 5-10
items, and I want the user to select the desired item via radiobutton. As it
is, the user can select as many radiobuttons as they want, which is
obviously not what I want. I want to limit the user to being able to select
one radiobutton at a time.
How can I add a...
| |
by: Tom |
last post by:
Hi
I have a usercontrol that inherits from
System.Windows.Forms.Usercontrol. As the Text property is not visable
in the IDE by default i am shadowing the property because i want ot
use it on the control.
This works fine and within the IDE i can set the text property,
however whenever i build the control this property is set to an empty...
|
by: Todd Jaspers |
last post by:
Hey guys,
I've added a list of items to a listbox in my C#/ASP web form. I allow
the user to select a few items, and then click a button. I want to be able to
retrieve the items from the list box that THAT user has selected and write it
to a string.
This is what I'm doing to read the text and it's not working:
|
by: MikeDiver |
last post by:
My first problem is that i was working on a project that had two radio buttons in it, i decided to delete one of them and now i cant get the second to activiate without being clicked (the second button makes the movie loop).
My second question, is there a piece of Actionscript code that works on all projects to create a looping clip?
Thanx...
|
by: Dustin MacDonald |
last post by:
Hi everyone.
This is my first time posting to this newsgroup, and although I
maintain my netiquette I might've missed something specific to the
newsgroup, so hopefully you can avoid flaming me if I have :) I
apologize for the length of this post but I figure the more
information the better.
My problem is that I'm getting a syntax error...
|
by: maxx233 |
last post by:
Hello,
I'm developing a simple program to control a video switcher we have via RS232. All the backend control stuff is figured out just fine, the interface is what's giving me problems! I'm basically just trying to figure out how to light up buttons depending on how they logically refer to each other, and I'm certain it should be simple, but I...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |