Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying XML info from online source
    primarykey
    data
    text
    <p>I am trying to create a web service in c# to display xml information pulled from an online source. The site is "<a href="http://www.omdbapi.com/?s=" rel="nofollow">http://www.omdbapi.com/?s=</a>"movieititle"&amp;r=XML" where I inserted Underworld as the title search. What came back from the website is :</p> <p>This XML file does not appear to have any style information associated with it. The document tree is shown below.</p> <pre><code>&lt;root response="True"&gt; &lt;Movie Title="Underworld" Year="2003" imdbID="tt0320691" Type="movie"/&gt; &lt;Movie Title="Underworld: Evolution" Year="2006" imdbID="tt0401855" Type="movie"/&gt; &lt;Movie Title="Underworld: Rise of the Lycans" Year="2009" imdbID="tt0834001" Type="movie"/&gt; &lt;Movie Title="Underworld: Awakening" Year="2012" imdbID="tt1496025" Type="movie"/&gt; &lt;Movie Title="Underworld U.S.A." Year="1961" imdbID="tt0055571" Type="movie"/&gt; &lt;Movie Title="Underworld" Year="1927" imdbID="tt0018526" Type="movie"/&gt; &lt;Movie Title="Tomb Raider: Underworld" Year="2008" imdbID="tt0972844" Type="game"/&gt; &lt;Movie Title="Hercules in the Underworld" Year="1994" imdbID="tt0110019" Type="movie"/&gt; &lt;Movie Title="Underworld" Year="1996" imdbID="tt0120414" Type="movie"/&gt; &lt;Movie Title="King of the Underworld" Year="1939" imdbID="tt0031536" Type="movie"/&gt; &lt;/root&gt; </code></pre> <p>The code that I have written to pull the info is as follows but for some reason it is not displaying anything in the textbox, but I know it is moving through the iterator as it displays "work" 10 times which is the number of entries. Any help would be appreciated.</p> <pre><code>private void button1_Click(object sender, EventArgs e) { txtResults.Clear(); HttpWebRequest myHttpWebRequest = null; HttpWebResponse myHttpWebResponse = null; XmlTextReader myXMLReader = null; XPathNavigator nav; XPathDocument docNav; String title = txtMovieKeywords.Text; String keyURL = "http://www.omdbapi.com/?s=" + title + "&amp;r=XML"; myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(keyURL); myHttpWebRequest.Method = "GET"; myHttpWebRequest.ContentType = "text/xml; encoding='utf-8'"; myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); myXMLReader = new XmlTextReader(myHttpWebResponse.GetResponseStream()); docNav = new XPathDocument(myXMLReader); nav = docNav.CreateNavigator(); XPathNodeIterator NodeIter; NodeIter = nav.Select("//root[@response='True']/Movie"); while (NodeIter.MoveNext()) { txtResults2.Text += NodeIter.Current.Value.ToString(); //txtResults2.Text += NodeIter.Current.SelectSingleNode("Movie[@Title]").ToString(); txtResults2.Text += "work"; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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