Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat’s wrong with this code
    primarykey
    data
    text
    <p>Why doesn't the while loop return anything? I assume this has something to do with .NET. I have .NET 2.0. The problem is that the while statement will execute one time then exit, as though there are no nodes with that name, when there definately are.</p> <p>Here is an example of the XML:</p> <pre><code>&lt;rss version="2.0"&gt; &lt;channel&gt; &lt;title&gt;...&lt;/title&gt; &lt;link&gt;...&lt;/link&gt; &lt;description&gt;...&lt;/description&gt; &lt;lastBuildDate&gt;...&lt;/lastBuildDate&gt; &lt;item&gt; &lt;title&gt;User greeting&lt;/title&gt; &lt;guid&gt;...&lt;/guid&gt; &lt;link&gt;http://...&lt;/link&gt; &lt;description&gt;Voicebox number: 1&lt;/description&gt; &lt;author&gt;Free Conference Call&lt;/author&gt; &lt;/item&gt; &lt;item&gt; &lt;title&gt;User greeting&lt;/title&gt; &lt;guid&gt;...&lt;/guid&gt; &lt;link&gt;http://...&lt;/link&gt; &lt;description&gt;Voicebox number: 1&lt;/description&gt; &lt;author&gt;Free Conference Call&lt;/author&gt; &lt;/item&gt; &lt;/channel&gt; &lt;/rss&gt; </code></pre> <p>Here is the code:</p> <pre><code>HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create (reqURL); // Set some reasonable limits on resources used by this request webreq.MaximumAutomaticRedirections = 4; webreq.MaximumResponseHeadersLength = 4; //==================== // Set credentials to use for this request. webreq.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse response = (HttpWebResponse)webreq.GetResponse (); //==================== // Get the stream associated with the response. receiveStream = response.GetResponseStream (); //==================== // Pipes the stream to a higher level stream reader with the required encoding format. readStream = new StreamReader(receiveStream, Encoding.UTF8); resXML = readStream.ReadToEnd(); readStream = new StreamReader(receiveStream, Encoding.UTF8); //==================== Console.WriteLine(resXML); Stream XMLStream = receiveStream; readStream = new StreamReader(XMLStream, Encoding.UTF8); XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.IgnoreWhitespace = true; settings.IgnoreComments = true; XmlReader reader = System.Xml.XmlReader.Create(readStream, settings); while(reader.EOF == false) { reader.ReadToFollowing("link"); Console.WriteLine("link: " + reader.Value); //======================================= reader.ReadToFollowing("description"); Console.WriteLine("descrip: " + reader.Value); } </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