struggleforlife 0 Newbie Poster

Looking for some help!

I have loaded XML doc into a dataset (see below). That went ok. So now I can put the DS in a grid and change it.
However, after changing the DS I want to export it back to a XML doc. That only succeeds partially.
I am getting a XML doc, but it's not like the original (see below). And I want it to be exactly like the original.
Maybe you brilliant guys can help me out!

The original XML code (I tried both with and without the Schema):

<?xml version="1.0" encoding="utf-8" ?> 
 <AppUsers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="usersnext.xsd">
 <User UserName="Dave">
  <UserPassword>Dave</UserPassword> 
  <SMSMaxDestinations>1000</SMSMaxDestinations> 
  <SMSDefaultSender>PROFICALL</SMSDefaultSender> 
  <SMSSenderChange>True</SMSSenderChange> 
  <SMSMaxCharacters>160</SMSMaxCharacters> 
  <SMSDateOption>365</SMSDateOption> 
  <SMSTimeOption>00:00:01-23:59:59</SMSTimeOption> 
  <SMSMaxTotal>1000</SMSMaxTotal> 
  <UserRole>ADMIN</UserRole> 
  <UserAccountStatus>ACTIEF</UserAccountStatus> 
  </User>
</AppUsers>

The code for exporting the DS to XML

Dim ds As New DataSet
        ds.Tables.Add(xDataTable)
        ds.ReadXmlSchema("usersnext.xsd")

        Dim xmlDoc As New XmlDocument
        xmlDoc.LoadXml(ds.GetXml())
        xmlDoc.Save(file)
        file.Close()
[/close]

The XML doc that is generated with the above code:

<NewDataSet>
- <User UserName="Dave">
  <UserPassword>Dave</UserPassword> 
  <SMSMaxDestinations>1000</SMSMaxDestinations> 
  <SMSDefaultSender>PROFICALL</SMSDefaultSender> 
  <SMSSenderChange>True</SMSSenderChange> 
  <SMSMaxCharacters>160</SMSMaxCharacters> 
  <SMSDateOption>365</SMSDateOption> 
  <SMSTimeOption>00:00:01-23:59:59</SMSTimeOption> 
  <SMSMaxTotal>1000</SMSMaxTotal> 
  <UserRole>ADMIN</UserRole> 
  <UserAccountStatus>ACTIEF</UserAccountStatus> 
  </User>
</NewDataSet>

Can you please help me changing the 'NewDataSet' into 'AppUsers' and adding the scheme-part?
Preferably a generic solution... So that i can turn it into a method that will export ány DS the right way.

Cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.