Solved

Needed Help on Converting from XmlNode to Dataset

Posted on 2004-09-12
2
682 Views
Last Modified: 2008-02-01
Dear All,

I have a problem here, I'm using C# Webform calling a webservices. The webservices return me a XMLnode, using this XMLnode I want to convert it to dataset so I can bind to the datagrid, by extracting the <CustomerData></CustomerData> block from the xmlnode.

Below is the sample of xmlnode return from webservices.

<?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>

How can it be done? Please provide some examples on this.
Thanks in advance.


Cheers,
yymae
0
Comment
Question by:yymae
2 Comments
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 12037936
0
 
LVL 5

Accepted Solution

by:
tomasX2 earned 100 total points
ID: 12039583
XmlNode node = webService.GetNode();
DataSet ds = new DataSet();
XmlReader reader = new XmlNodeReader(node);
ds.ReadXml(reader);
dataGrid1.DataSource = ds.Tables["CustomerData"];
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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