i created a xmlfile from your node list but as i said you can directly use
the OuterXML
i will copy contents off each file and add those here. Hope this helps
Customers.xml
---------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<OutputParams>
<CustomerData>
<CustomerID>1</CustomerID>
<CustomerName>TEST1</CustomerName>
<Gender>M</Gender>
<DateOfBirth>19800101</DateOfBirth>
</CustomerData>
<CustomerData>
<CustomerID>1</CustomerID>
<CustomerName>TEST2</CustomerName>
<Gender />
<DateOfBirth>19000101</DateOfBirth>
</CustomerData>
<CustomerData>
<CustomerID>3</CustomerID>
<CustomerName>TEST3</CustomerName>
<Gender />
<DateOfBirth>19000101</DateOfBirth>
</CustomerData>
<ReturnCode>0</ReturnCode>
<ErrorCode>0</ErrorCode>
<ErrorDescription />
</OutputParams>
---------------------------------------------------
Customers.xsd (used xsd to load the schema - Cause you do not want the
Return Code ErrorCode & Description in the dataset)
---------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="OutputParams" xmlns=""
xmlns:xs="
http://www.w3.org/2001/XMLSchema">
<xs:element name="OutputParams">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="CustomerData">
<xs:complexType>
<xs:sequence>
<xs:element name="CustomerID" type="xs:int"></xs:element>
<xs:element name="CustomerName" type="xs:string"></xs:element>
<xs:element name="Gender" type="xs:string"></xs:element>
<xs:element name="DateOfBirth" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
---------------------------------------------------
StepByStep2_9.cs
---------------------------------------------------
using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml;
namespace StepByStep
{
/// <summary>
/// Summary description for StepByStep2_9.
/// </summary>
public class StepByStep2_9 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dgXML;
private System.Windows.Forms.Button btnLoadXML;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public StepByStep2_9()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgXML = new System.Windows.Forms.DataGrid();
this.btnLoadXML = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dgXML)).BeginInit();
this.SuspendLayout();
//
// dgXML
//
this.dgXML.DataMember = "";
this.dgXML.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgXML.Location = new System.Drawing.Point(16, 64);
this.dgXML.Name = "dgXML";
this.dgXML.Size = new System.Drawing.Size(568, 200);
this.dgXML.TabIndex = 3;
//
// btnLoadXML
//
this.btnLoadXML.Location = new System.Drawing.Point(16, 24);
this.btnLoadXML.Name = "btnLoadXML";
this.btnLoadXML.TabIndex = 2;
this.btnLoadXML.Text = "Load XML";
this.btnLoadXML.Click += new System.EventHandler(this.btnLoadXML_Click);
//
// StepByStep2_9
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(600, 285);
this.Controls.Add(this.dgXML);
this.Controls.Add(this.btnLoadXML);
this.Name = "StepByStep2_9";
this.Text = "StepByStep2_9";
this.Load += new System.EventHandler(this.StepByStep2_9_Load);
((System.ComponentModel.ISupportInitialize)(this.dgXML)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new StepByStep2_9());
}
private void btnLoadXML_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXmlSchema(@"..\..\Customers.xsd");
// create matching xml data document
XmlDataDocument xdd = new XmlDataDocument(ds);
try
{
xdd.Load(@"..\..\Customers.xml");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error Loading XML");
}
this.dgXML.DataSource = ds;
this.dgXML.DataMember = "CustomerData";
}
}
}
--
Regards,
Hermit Dave
(
http://hdave.blogspot.com)