I’m new to Web Services and XML and was tasked to parse an XML response packet returned.
What’s the best way to parse an XML result in C#.NET?
I need to bind to a data grid as the end result from a search query.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you have access to the wsdl for the webservice, there is a utility
wsdlthat will generate the needed classes and deserialization to call a webservice and parse its response into those classes.Using the example webservice at w3schools, you would just run this command line:
That would generate a file TempConvert.cs that you could add into your project. Then calling the webservice is just a matter of calling the generated functions:
That TempConvert class takes care of the details of building an XML query, contacting the webservice, and parsing the reply back in. This is a super-simple example, so you only get a string back, but since your webservice is likely to be a little more complicated, you’ll get back more complicated classes containing the data you want in a parsed form. Depending on the complexity of the web service, this could even be as simple as an array of strings, or as complex as a giant class heirarchy.