Solved

DataSet to XML

Posted on 2009-04-03
1
525 Views
Last Modified: 2012-05-06
Hi,

I am exporting a dataset to an XML file and I am having trouble getting the root node to be correct.  I am using Visual Studio 2008, ASP.NET C#.  My XML needs to be in the following format:

- <Navision_SO_1>
- <General>
  <Customer_Number>CC0001</Customer_Number>
  <External_Document_Number>85710</External_Document_Number>
  <Requested_Delivery_Date>02/04/2009</Requested_Delivery_Date>
  <Ship_To_Code>011</Ship_To_Code>
  </General>
- <Lines>
  <External_Document_Number>85710</External_Document_Number>
  <Number>0</Number>
  <Quantity>1</Quantity>
  </Lines>
</Navision_SO_1>

Instead I am getting the following - note the different root node:

- <NewDataSet xmlns="Navision_SO_1">
- <General>
  <Customer_Number>CC0001</Customer_Number>
  <External_Document_Number>85710</External_Document_Number>
  <Requested_Delivery_Date>02/04/2009</Requested_Delivery_Date>
  <Ship_To_Code>011</Ship_To_Code>
  </General>
- <Lines>
  <External_Document_Number>85710</External_Document_Number>
  <Number>0</Number>
  <Quantity>1</Quantity>
  </Lines>
</NewDataSet>

I am using the code below to change the names but it isn't working correctly. Any help greatly appreciated.

Mike
// Step 2d - Sort out the names so the Xml looks correct

tempDs.Tables["Order_Header"].TableName = "General";

tempDs.Tables["Order_Details"].TableName = "Lines";

tempDs.Namespace = "Navision_SO_1";

Open in new window

0
Comment
Question by:hydev
1 Comment
 
LVL 16

Accepted Solution

by:
sunithnair earned 500 total points
ID: 24060461
Set the name of the dataset instead of the Namespace
// Step 2d - Sort out the names so the Xml looks correct

tempDs.Tables["Order_Header"].TableName = "General";

tempDs.Tables["Order_Details"].TableName = "Lines";

tempDs.DataSetName = "Navision_SO_1";

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now