Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DataSet to XML

Posted on 2009-04-03
1
Medium Priority
?
534 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

660 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