Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
REST web service
Message
Information générale
Forum:
Internet
Catégorie:
Autre
Divers
Thread ID:
01612361
Message ID:
01612392
Vues:
51
Thanks Rick

I realised that (as the later code fails because as you say the stream has been "used") but this was a temporary measure as I wanted to see what was in the stream.

>That won't work because the stream is read-once. You'll be at the end of the stream.
>
>Viv's idea is the right one - read the stream to a string (or to some other stream like a TextWriter), adjust if needed then use Load() to explicitly load the string... Unless the XML is enormous this is very fast - what's slow is the IO operations of reading the data from the stream over the network.
>
>
>+++ Rick ---
>
>>public static string getElementValue(string elementName,Stream stream)
>> {
>> StreamReader reader = new StreamReader(stream);
>> string fileInfo = reader.ReadLine();
>> XDocument doc = XDocument.Load(stream);
>> return (from element in doc.Descendants(elementName)
>> select element).Single().Value;
>> }
>>
>>and in debug fileinfo is empty. Would I expect to see a response in there ? Can I access this stream like that ?
>>
>>Update I changed readline to ReadToEnd and now I can see its returning a web page which is wrong. thats some progress I guess
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform