Solved

DataSet to XML

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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

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.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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