Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DataSet to XML

Posted on 2009-04-03
1
Medium Priority
?
537 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

782 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