Solved

DataSet to XML

Posted on 2009-04-03
1
526 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Events in static methods 3 50
XML to Excel using XSL - formatting 3 26
Please explain "Multi-Tenant Services" 5 63
SQL XML ALL Nodes Compare in function 2 17
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 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

22 Experts available now in Live!

Get 1:1 Help Now