473,652 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populate and Merge DataSet to form an XML

Hi,

I need to populate and merge DataSet to make an XML in the following format:

<?xml version="1.0" standalone="yes "?>
<CompanyOrder s>
<CompanyProfile >
<CompanyID>Test </CompanyID>
<CompanyName>Th e Company</CompanyName>
</CompanyProfile>
<OrderInformati on>
<BuyerInformati on>
<OrderNo>0000 1</OrderNo>
</BuyerInformatio n>
</OrderInformatio n>
</CompanyOrders>

So far I am able to come up with this code:

DataSet dsCompanyOrders = new DataSet("Compan yOrders");
DataTable dt = dsCompanyOrders .Tables.Add("Co mpanyProfile");
DataColumn dcCompanyID = new DataColumn("Com panyID");
DataColumn dcCompanyName = new DataColumn("Com panyName");
dt.Columns.AddR ange(new DataColumn[]
{
dcCompanyID,dcC ompanyName
}
);
DataRow drCompanyProfil e = dt.NewRow();
drCompanyProfil e["CompanyID"] = "Test";
drCompanyProfil e["CompanyNam e"] = "The Company";
dt.Rows.Add(drC ompanyProfile);

DataSet dsOrderInformat ion = new DataSet("OrderI nformation");
DataTable dtBuyerInformat ion =
dsOrderInformat ion.Tables.Add( "BuyerInformati on");
DataColumn dcOrderNo = new DataColumn("Ord erNo");
dtBuyerInformat ion.Columns.Add (dcOrderNo);
DataRow drOrderInformat ion = dtBuyerInformat ion.NewRow();
drOrderInformat ion["OrderNO"] = "00001";
dtBuyerInformat ion.Rows.Add(dr OrderInformatio n);
dsCompanyOrders .Merge(dsOrderI nformation,fals e,MissingSchema Action.Add);

dsCompanyOrders .WriteXml("c:\\ test.xml",XmlWr iteMode.IgnoreS chema);

The problem is that I cant create the parent node <OrderInformati on> and the
XML that is created is as follows:

<?xml version="1.0" standalone="yes "?>
<CompanyOrder s>
<CompanyProfile >
<CompanyID>Test </CompanyID>
<CompanyName>Th e Company</CompanyName>
</CompanyProfile>
<BuyerInformati on>
<OrderNo>0000 1</OrderNo>
</BuyerInformatio n>
</CompanyOrders>

Need some help with this :S

Thanks, Nauman.
Nov 16 '05 #1
0 1039

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

Similar topics

3
1650
by: Li Weng | last post by:
Hi, I have an original dataset. It is copied to 2 different forms. Each form adds a new row to the same table in that dataset. When I merge these 2 dataset back to original one, the 2 new rows merge to one! My question is how I can still keep them as 2 rows in that table, not merge to one? Thanks. Li
4
2351
by: John Smith | last post by:
..Net 2003 C# I get xml from a sql database pull. I put the data into a XMLDomDocument and then the user changes it. I now need to update the database correctly. I need to be able to get the data back correctly including add, change and delete to the original data. When I pull the data from the db, I store a copy in a Dataset. So I end up with a Dataset (original data) and an XML DOM Document with the changed data.
7
6221
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data in the same format as the XSD (the XML file/string was created using this same schema). The XML file/string may contain data for a single table or for several tables at once. The question is:
3
2689
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to populate multiple webpages containing customer information. There isn't a one-to-one correlation between the stored procedure and a webpage. In other words, a webpage may have to refer to 1 or more DataTables to populate itself. Therefore, a...
2
4290
by: Mike Stephens | last post by:
A contact management application we previously developed for a customer now has a requirement to perform mail merging. Normally request like this would be very simple to solve, we were just point the mail merge data source to the database. But this request is a little bit different. The customer needs to perform the mail merge from the contacts in a dataset. Example In the main contact window the client has the ability to filter contact...
2
2103
by: muntyanu | last post by:
Hi all, I have problem when merging existing DataTable into new dataset. DataSet ds = new DataSet(); while ( done ) { // fill myCustomDataSet.MyTable with data ds.Merge( myCustomDataSet.MyTable, bPreserveChanges, MissingSchemaAction.Add ); ds.AcceptChanges(); // tried with and without this line
0
1033
by: Allen | last post by:
We converted our app from 1.1 to 2 and some code was no longer working. The case: From a non typed datatable, convert it to a typed one. How to reproduce the bug: ------------------------------- 1) Create a project. 2) Add a new Dataset (keep DataSet1). a) Add a new DataTable (Keep DataTable1) b) Add a new DataColumn (Keep DataColumn1) 3) Add a new Window form.
5
16704
by: Mark Chambers | last post by:
Hi there, Can anyone explain the following (very) simple scenario. 1) I make an exact copy of my "DataSet" and delete one record from a given table (in the copy) 2) I invoke "DataSet.GetChanges()" on the above copy and pass the results to "DataSet.Merge()" on the original copy 3) If I now inspect the original copy, it shows that the record has *not* been deleted from the table. However, a call to "GetChanges()" does show my
1
6167
by: joproulx | last post by:
Hello all, Here is my problem: I am trying to merge 2 datasets but I don't want to overwrite rows that are already modified in my working dataset. Example: I have one Dataset with only one DataTable in it. The DataTable has these 2 columns: Column #1: Name="Id" Type=Int32 (Primary Key)
0
8811
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
8470
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
8590
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
7302
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
6160
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
5620
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2707
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
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
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.