473,396 Members | 2,036 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,396 software developers and data experts.

Question about XMLDataDocument

I'm relatively new to this sort of thing, so forgive me if this is
completely off base, but I'm having a problem getting the
XMLDataDocument to do what I need it to.

I have a small test application that has a DataSet with two data
tables, Person and Home. I've setup Home as a child of Person. What
I want to do is to load data into these two tables, and then have the
data document create the xml with the child nodes (home) nested under
the parent node (person). Is this possible??? The code snippet I
have to load and output the xml is as follows:

DsTester ds = new DsTester();
DsTester.PersonDataTable pdt =
(DsTester.PersonDataTable)ds.Tables["Person"];
DsTester.HomeDataTable hdt =
(DsTester.HomeDataTable)ds.Tables["Home"];
pdt.AddPersonRow(12,"John");
hdt.AddHomeRow(1,pdt[0], "MyHome");
XmlDataDocument xdoc = new XmlDataDocument(ds);
System.Diagnostics.Debug.WriteLine(xdoc.OuterXml);
What it outputs is:
<DsTester xmlns="http://tempuri.org/Dataset1.xsd">
<Person>
<PersonID>12</PersonID>
<Name>John</Name>
</Person>
<Home>
<HomeID>1</HomeID>
<PersonID>12</PersonID>
<HomeName>MyHome</HomeName>
</Home>
</DsTester>
What I want it to output is:
<DsTester xmlns="http://tempuri.org/Dataset1.xsd">
<Person>
<PersonID>12</PersonID>
<Name>John</Name>
<Home>
<HomeID>1</HomeID>
<HomeName>MyHome</HomeName>
</Home>
</Person>
</DsTester>

Is this possible, or am I going to have to roll my own?
Thanks!!!
Jul 21 '05 #1
1 1282
Mathew,

I think that you are searching for this information (look at nested)

http://msdn.microsoft.com/library/de...arelations.asp

I hope this helps?

Cor

"Mathew Relick" <ti****@yahoo.com>
I'm relatively new to this sort of thing, so forgive me if this is
completely off base, but I'm having a problem getting the
XMLDataDocument to do what I need it to.

I have a small test application that has a DataSet with two data
tables, Person and Home. I've setup Home as a child of Person. What
I want to do is to load data into these two tables, and then have the
data document create the xml with the child nodes (home) nested under
the parent node (person). Is this possible??? The code snippet I
have to load and output the xml is as follows:

DsTester ds = new DsTester();
DsTester.PersonDataTable pdt =
(DsTester.PersonDataTable)ds.Tables["Person"];
DsTester.HomeDataTable hdt =
(DsTester.HomeDataTable)ds.Tables["Home"];
pdt.AddPersonRow(12,"John");
hdt.AddHomeRow(1,pdt[0], "MyHome");
XmlDataDocument xdoc = new XmlDataDocument(ds);
System.Diagnostics.Debug.WriteLine(xdoc.OuterXml);
What it outputs is:
<DsTester xmlns="http://tempuri.org/Dataset1.xsd">
<Person>
<PersonID>12</PersonID>
<Name>John</Name>
</Person>
<Home>
<HomeID>1</HomeID>
<PersonID>12</PersonID>
<HomeName>MyHome</HomeName>
</Home>
</DsTester>
What I want it to output is:
<DsTester xmlns="http://tempuri.org/Dataset1.xsd">
<Person>
<PersonID>12</PersonID>
<Name>John</Name>
<Home>
<HomeID>1</HomeID>
<HomeName>MyHome</HomeName>
</Home>
</Person>
</DsTester>

Is this possible, or am I going to have to roll my own?
Thanks!!!

Jul 21 '05 #2

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

Similar topics

1
by: Peter Feakins | last post by:
We're building some web services that are primarily being consumed by a .net application. We're returning datasets for that purpose. We're also have to provide access to these services to classic...
1
by: Jim Bancroft | last post by:
Hi, I'm porting a VB 6 app to .Net, and wanted to use an XMLDataDocument to store information that had previously been kept in XML Recordsets. Unfortunately, I'm not too familiar yet with...
0
by: gilly3 | last post by:
Reposting to a more relevant group. I am passing a generic dataset into a new XMLDataDocument and then parsing the XML with XSLT. The idea being that I can parse any dataset with the same xslt,...
2
by: James Ankrom | last post by:
Why does this fail? Dim relResources As New Data.DataRelation("Application_Resources", ..Tables("User_Applications").Columns("Application_id"),...
10
by: Steven Blair | last post by:
Hi, Quick overview of the problem: public bool Something( out DataSet ds ) { bool ret=false; try {
0
by: Steve | last post by:
I have a dataset. I fill it with two recordsets from SQL queries. Tables are called tblPlanFYSpendingStage, tblSpendingStage.
4
by: Adrian Meyer | last post by:
Hi, On the server I code the following web service: ))] public XmlDataDocument GetTypedXmlDataDocument() { sqlDataAdapter1.Fill(typedDataSet1); XmlDataDocument dataDoc
1
by: Mathew Relick | last post by:
I'm relatively new to this sort of thing, so forgive me if this is completely off base, but I'm having a problem getting the XMLDataDocument to do what I need it to. I have a small test...
1
by: JD | last post by:
I have a DataGridView with a DataSet as DataSource. The user can update the contents of the DataGridView, and then click on a Save button to save the data to an XML file. When they click on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
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
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,...

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.