Solved

Needed Help on Converting from XmlNode to Dataset

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now