title: Parsing Soap XML
body: <p>I have a XML like this:    </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;soap:Body&gt;
          &lt;SampleResponse xmlns="http://tempuri.org/"&gt;
              &lt;SampleResult&gt;
                  &lt;diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
                                   xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"&gt;
                      &lt;NewDataSet xmlns=""&gt;
                          &lt;Table diffgr:id="Table1" msdata:rowOrder="0"&gt;
                              &lt;tag1&gt;tag1 text&lt;/tag1&gt;
                              &lt;tag2&gt;tag2 text&lt;/tag2&gt;
                          &lt;/Table&gt;
                          &lt;Table diffgr:id="Table2" msdata:rowOrder="1"&gt;
                              &lt;tag1&gt;tag1 text&lt;/tag1&gt;
                              &lt;tag2&gt;tag2 text&lt;/tag2&gt;
                          &lt;/Table&gt;
                      &lt;/NewDataSet&gt;
                  &lt;/diffgr:diffgram&gt;
              &lt;/SampleResult&gt;
          &lt;/SampleResponse&gt;
      &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>So i parsed above XML using Below Code:</p>
  
  <pre><code>string XMLresponse = e.response;
  var XResult = XElement.Parse(XMLresponse);
  
  var result = XResult.Descendants("Table")
      .Select(t =&gt; new
      {
          tag1 = t.Descendants("tag1").First().Value,
          tag2 = t.Descendants("tag2").First().Value,
      });
  
  foreach (var res in result)
  {
     string str = res.tag1; // here i am able get the response
  }
  
  listbox.ItemsSource = result;
  </code></pre>
  
  <p>But i am not able bind it to ListBox. i have a ListBox like below: </p>
  
  <pre><code>&lt;ListBox x:Name="listbox"&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;StackPanel Orientation="Vertical"&gt;
                  &lt;TextBlock Text="Sample" &gt;&lt;/TextBlock&gt;
                  &lt;TextBlock Text="{Binding tag1}" &gt;&lt;/TextBlock&gt;
                  &lt;TextBlock Text="{Binding tag2}" &gt;&lt;/TextBlock&gt;
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>In the ListBox i have added a TextBlock, which is repeated twice. But the dynamical text blocks are not binding with data.</p>