I'm new to Web services and XML and I was assigned to parse an XML response packet.
What is the best way to parse XML in C # .NET?
I need to bind to the data grid as a last result from a search grid.
If you have access to wsdl for the webservice, then a feature wsdl
Call the webservice which will generate the necessary sections and deserialization and parse your response in those classes.
Using the webservice in the example, you can run this command line:
wsdl "http: // www w3schools.com/webservices/tempconvert.asmx?WSDL "
This will generate a file TempConvert.cs that you can add to your project, then calling the webservice is a matter of calling only the jobs generated:
< Pre> double fahrenheit = 32.2; TempConvert tempConverter = New TempConvert (); String Celsius = Temp Connor. Fahrenheit Los Angeles (Fahrenheit ToString ());
That template takes care of the details of creating class XML queries, contacting WebService, and parsing the answer back. This is a super simple example, so you only get a string back, but when your website is likely to be a bit more complex, you will find more complex classes that want data in the purse form. Depending on the complexity of the web service, it can be as simple as an array of strings or complex as a succession of a large class.
Comments
Post a Comment