In C#, if I need to open an HTTP connection, download XML and get one value from the result, how would I do that?
For consistency, imagine the webservice is at http://www.webservice.com and that if you pass it the POST argument fXML=1 it gives you back
<xml><somekey>somevalue</somekey></xml>
I’d like it to spit out ‘somevalue’.
I use this code and it works great:
EDIT: I just realized you’re talking about a webservice and not just plain XML. In your Visual Studio Solution, try right clicking on References in Solution Explorer and choose ‘Add a Web Reference’. A dialog will appear asking for a URL, you can just paste it in: ‘http://www.webservice.com/webservice.asmx‘. VS will autogenerate all the helpers you need. Then you can just call: