Sunday, 18 August 2013

Parsing Dictionary Value in a WebRequest

Parsing Dictionary Value in a WebRequest

I have a WebAPI service that returns result as KeyValue pair (Dictionary).
I use web Request to get the response. The Result is like
<ArrayOfKeyValueOfstringanyType
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<KeyValueOfstringanyType>
<Key>Department</Key>
<Value xmlns:d3p1="http://www.w3.org/2001/XMLSchema"
i:type="d3p1:string">IT</Value>
</KeyValueOfstringanyType>
</ArrayOfKeyValueOfstringanyType>
How can I parse this reponse by using Webrequest in C#?
var serverUrl = new Uri("MyServiceURL");
var request = WebRequest.Create(serverUrl) as HttpWebRequest;
var itemResponse = (HttpWebResponse)itemRequest.GetResponse();

No comments:

Post a Comment