Solved

Needed Help on Converting from XmlNode to Dataset

Posted on 2004-09-12
2
685 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

766 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