Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to parse xml string from Post method response?
    primarykey
    data
    text
    <p>I have a xml string that return from Post method:</p> <pre><code>private static void GetResponseCallback(IAsyncResult asynchronousResult) { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; // End the operation HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); HttpStatusCode rcode = response.StatusCode; var stream = new GZipInputStream(response.GetResponseStream()); using (StreamReader reader = new StreamReader(stream)) { responseString = reader.ReadToEnd(); } response.Close(); } </code></pre> <p>The responseString is the string I want to parse, using parseXmlString class below. However I can't call the method parseXmlString directly because of the static. How can I pass the responseString to the parseXmlString method to have them parse out and bind to the listBox. Or anyway to have the same result would be great.</p> <pre><code>void parseXmlString() { byte[] byteArray = Encoding.UTF8.GetBytes(responseString); MemoryStream str = new MemoryStream(byteArray); str.Position = 0; XDocument xdoc = XDocument.Load(str); var data = from query in xdoc.Descendants("tracks").Elements("item") select new searchResult { artist = (string)query.Element("artist"), album = (string)query.Element("album"), track = (string)query.Element("track"), // artistA = (string)query.Element("artists").Element("artist"), }; // ListBox lb = new ListBox(); listBox1.ItemsSource = data; var data1 = from query in xdoc.Descendants("artists").Elements("item") select new searchResult { artistA = (string)query.Element("artist"), }; listBox2.ItemsSource = data1; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload