c# - What’s wrong with this code -


Why does the loop do not return anything? I think it has to do something with .NET. I have .NET 2.0. The problem is that the time statement will execute once, then exit, as if there are no nodes with that name, when it is definitely.

Here is an example of XML:

  & 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; Items & gt; & Lt; Title & gt; User greeting & lt; / Title & gt; & Lt; GUID & gt; ... & lt; / GUID & gt; & Lt; Link & gt; Http: //...< / Link & gt; & Lt; Details & gt; Voicembox number: 1 & lt; / Description & gt; & Lt; Author & gt; Free conference calls & lt; / Author & gt; & Lt; / Item & gt; & Lt; Items & gt; & Lt; Title & gt; User greeting & lt; / Title & gt; & Lt; GUID & gt; ... & lt; / GUID & gt; & Lt; Link & gt; Http: //...< / Link & gt; & Lt; Details & gt; Voicembox number: 1 & lt; / Description & gt; & Lt; Author & gt; Free conference calls & lt; / Author & gt; & Lt; / Item & gt; & Lt; / Channel & gt; & Lt; / Rss & gt;  

Here is the code:

  http webbrake webreak = (http webbrand) webquestion.net (reql); // Set some reasonable limits on the resources used by this request webreq.MaximumAutomaticRedirections = 4; Webreq.MaximumResponseHeadersLength = 4; // ==================== Set the credentials to use for this request Webreq.Credentials = Credential cache. Default credentials; HttpWebResponse response = (HttpWebResponse) webreq.GetResponse (); Get the stream associated with the // ==================== feedback. Receivedstream = response GetResponseStream (); Pip the stream // // =================== Stream with the required encoding format in a high level stream reader. ReadStream = New Streamerder (Received Stream, Encoding. UTF8); ResXML = readStream.ReadToEnd (); ReadStream = New Streamerder (Received Stream, Encoding. UTF8); // ==================== Console: WriteLine (resXML); Stream XMLStream = GetStream; ReadStream = New Streamerder (XMLStream, Encoding.UTF8); XmlReaderSettings Settings = New XmlReaderSettings (); Settings.configenval = Confidencelive Fragment; Settings.IgnoreWhitespace = true; Settings.IgnoreComments = true; XmlReader Reader = System.Xml.XmlReader.Create (ReadStream, Settings); While (reader.EOF == incorrect) {reader.ReadToFollowing ("link"); Console.light line ("link:" + reader.Value); // ======================================= Reader Reed tolling ("description"); Console.light line ("descrip:" + reader.Value); }  

When you call, then you already read all the data from the reaction Have been P>

  resXML = ReaderStream. Readout ();   

... reader stream and readstream are both layered on the top of the received stream , so once you 'You have read all the data through one, you can not read it again through another.

You should actually use the statement for a response statement - and ideally comprises different streams. Given that you can create a XmlReader from a stream, not just a streamerdidder , why not just use something like this:

 < Code> XmlReaderSettings Settings = New XmlReaderSettings (); Settings.configenval = Confidencelive Fragment; Settings.IgnoreWhitespace = true; Settings.IgnoreComments = true; {{XML Datetime}}} (HTTP Webbation Response = (HTTP Webbashings) = (HTTP Web Response) webreak. (GETTERS) (using XMLReader Reader = XML Reader. CREATE (Stream, Settings)) {Uses (Stream Stream = Response. Gate Responsestream ())   

Additionally, Typically XmlDocument or XmlReader Instead of working with them, suggest something similar - this big Documents do not even scale for documents, but it's easy to work with.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -