views:

271

answers:

2

I have added web service reference in visual studio. I am able to see xml return value from web method. How should I read data from returned XML of service?

+1  A: 

You can use LINQ to XML for primitive information extracting if you're doing something simple.

Alternatively, if you're using WCF and you have access to the .NET interfaces used to spec the web service you can get objects out of the other end (look into Data Contracts).

Joe
web service is not developed in wcf.
Novice Developer
Then look into LINQ and see if it's enough for your needs. http://msdn.microsoft.com/en-us/vbasic/bb688087.aspx
Joe
+1  A: 

You can parse the return XML using LINQ (new-school) or XmlDocument (old-school) if you want access to basic information in the payload.

If you'd like to treat the entire response as a strongly-typed object, look into creating your own classes and de-serialize the request into those objects. This can be a little more complex, but can also provide strong typing for dealing with changes from the service provider (you'll know when it breaks.) The DataContractSerializer class (used for WCF) provides the fastest and most efficient serializer within the .Net Framework as a point of reference.

My preference is the strongly-typed object for reasons stated.

jro