Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to convert XML data of web service into DataSet

79 views
Skip to first unread message

shakthi

unread,
Jul 10, 2007, 4:42:43 PM7/10/07
to
Hi all,....i am developing an pocket PC application which consumes
USZip Webservice and display the data.

USZip has a GetInfoByZip(String zipcode) method which retuns an XML
data......

For Example....

USZip u = new USZip();

System.Console.WriteLine(u.GetInfoByZip("49544"));

****OutPut************
<?xml version="1.0" encoding="utf-8" ?>
- <NewDataSet>
- <Table>
<CITY>Grand Rapids</CITY>
<STATE>MI</STATE>
<ZIP>49544</ZIP>
<AREA_CODE>616</AREA_CODE>
<TIME_ZONE>E</TIME_ZONE>
</Table>
</NewDataSet>
********************************
I want this data to be displayed into a dataset....i tried using
DataSet.ReadXml(u.GetInfoByZip("49544"))...but iam getting an error
saying cannot convert Xml.XMlNode data into String..may be because
ReadXml() don't hav such type of argument......can any tell me how to
convert this Xml data into DataSet..................thankyou

sloan

unread,
Jul 10, 2007, 4:57:11 PM7/10/07
to

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!148.entry

You're lucky day!

Xml To Xml Conversion

"shakthi" <shak...@gmail.com> wrote in message
news:1184100163.9...@o61g2000hsh.googlegroups.com...

sloan

unread,
Jul 10, 2007, 5:59:10 PM7/10/07
to

Also look at this code:


private EmpDataDSWithValidateMethod GetDataSet1()
{
EmpDataDSWithValidateMethod ds = new EmpDataDSWithValidateMethod();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<?xml version=\"1.0\"?><EmpDataDS>");
sb.Append("<Emp>");
sb.Append("<EmpID>123</EmpID>");
sb.Append("<LastName>Smith</LastName>");
sb.Append("<FirstName>John</FirstName>");
sb.Append("<SSN>222-22-2222</SSN>");
sb.Append("<DateOfBirth>" + DateTime.Now.ToLongDateString() +
"</DateOfBirth>");
sb.Append("</Emp>");


sb.Append("<Emp>");
sb.Append("<EmpID>456</EmpID>");
sb.Append("<LastName>Jones</LastName>");
sb.Append("<FirstName>Mary</FirstName>");
sb.Append("<SSN>333-33-3333</SSN>");
sb.Append("<DateOfBirth>01/01/1972</DateOfBirth>");
sb.Append("</Emp>");


sb.Append("</EmpDataDS>");

System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.IO.StreamWriter writer = new System.IO.StreamWriter(ms);
writer.Write(sb.ToString());
writer.Flush();
ms.Position = 0;
ds.ReadXml(ms);
return ds;

}

My sb.Append to make up a dataset is BAD coding (this is just sample code
above for testing), BUT check out how you can ReadXml a stream object.

"sloan" <sl...@ipass.net> wrote in message
news:e008jTz...@TK2MSFTNGP06.phx.gbl...

shakthi

unread,
Jul 11, 2007, 12:32:48 PM7/11/07
to
> "sloan" <s...@ipass.net> wrote in message

>
> news:e008jTz...@TK2MSFTNGP06.phx.gbl...
>
>
>
>
>
> >http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!148.entry
>
> > You're lucky day!
>
> > Xml To Xml Conversion
>
> > "shakthi" <shakth...@gmail.com> wrote in message

> >news:1184100163.9...@o61g2000hsh.googlegroups.com...
> >> Hi all,....i am developing an pocket PC application which consumes
> >> USZip Webservice and display the data.
>
> >> USZip has a GetInfoByZip(String zipcode) method which retuns an XML
> >> data......
>
> >> For Example....
>
> >> USZip u = new USZip();
>
> >> System.Console.WriteLine(u.GetInfoByZip("49544"));
>
> >> ****OutPut************
> >> <?xml version="1.0" encoding="utf-8" ?>
> >> - <NewDataSet>
> >> - <Table>
> >> <CITY>Grand Rapids</CITY>
> >> <STATE>MI</STATE>
> >> <ZIP>49544</ZIP>
> >> <AREA_CODE>616</AREA_CODE>
> >> <TIME_ZONE>E</TIME_ZONE>
> >> </Table>
> >> </NewDataSet>
> >> ********************************
> >> I want this data to be displayed into a dataset....i tried using
> >> DataSet.ReadXml(u.GetInfoByZip("49544"))...but iam getting an error
> >> saying cannot convert Xml.XMlNode data into String..may be because
> >> ReadXml() don't hav such type of argument......can any tell me how to
> >> convert this Xml data into DataSet..................thankyou- Hide quoted text -
>
> - Show quoted text -

but the GetInfoByZip("xx") is a XMLNode data...so how can i take this
into string???

0 new messages