473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GetResponseStream returns Junk characters

SKG
Iam trying to read an xml file from a website and i get junk characters. But
when i open the same file in browser
everything is fine.
here is the snippet of the code

WebRequest objRequest =
WebRequest.Create("http://www.xvdabc.com/order.xml");
WebResponse objResponse = objRequest.GetResponse();
StreamReader SR = new StreamReader(objResponse.GetResponseStream());
string strContent = oSR.ReadToEnd();
strContent has junk characters
TIA


Nov 16 '05 #1
7 6652
SKG,

What is the encoding of the stream that is being returned? You should
specify the encoding to the StreamReader so that the bytes returned are
encoded correctly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:Ox****************@TK2MSFTNGP12.phx.gbl...
Iam trying to read an xml file from a website and i get junk characters. But when i open the same file in browser
everything is fine.
here is the snippet of the code

WebRequest objRequest =
WebRequest.Create("http://www.xvdabc.com/order.xml");
WebResponse objResponse = objRequest.GetResponse();
StreamReader SR = new StreamReader(objResponse.GetResponseStream());
string strContent = oSR.ReadToEnd();
strContent has junk characters
TIA

Nov 16 '05 #2
SKG
Iam using following encoding.

Encoding encoding = System.Text.Encoding.GetEncoding("utf-8");

TIA

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
SKG,

What is the encoding of the stream that is being returned? You should
specify the encoding to the StreamReader so that the bytes returned are
encoded correctly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:Ox****************@TK2MSFTNGP12.phx.gbl...
Iam trying to read an xml file from a website and i get junk characters.

But
when i open the same file in browser
everything is fine.
here is the snippet of the code

WebRequest objRequest =
WebRequest.Create("http://www.xvdabc.com/order.xml");
WebResponse objResponse = objRequest.GetResponse();
StreamReader SR = new StreamReader(objResponse.GetResponseStream());
string strContent = oSR.ReadToEnd();
strContent has junk characters
TIA


Nov 16 '05 #3
SKG
after GetResponse I found the response
object has followingproperties
ContentEncoding "x-gzip"
ContentType "text/xml" string
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
SKG,

What is the encoding of the stream that is being returned? You should
specify the encoding to the StreamReader so that the bytes returned are
encoded correctly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:Ox****************@TK2MSFTNGP12.phx.gbl...
Iam trying to read an xml file from a website and i get junk characters.

But
when i open the same file in browser
everything is fine.
here is the snippet of the code

WebRequest objRequest =
WebRequest.Create("http://www.xvdabc.com/order.xml");
WebResponse objResponse = objRequest.GetResponse();
StreamReader SR = new StreamReader(objResponse.GetResponseStream());
string strContent = oSR.ReadToEnd();
strContent has junk characters
TIA


Nov 16 '05 #4
SKG,

I don't believe that the HttpWebResponse class understands how to handle
compressed content. Because of this, you will have to run the stream
through an algorithm that will decompress the stream accoding to the x-gzip
protocol.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
after GetResponse I found the response
object has followingproperties
ContentEncoding "x-gzip"
ContentType "text/xml" string
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
SKG,

What is the encoding of the stream that is being returned? You should specify the encoding to the StreamReader so that the bytes returned are
encoded correctly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:Ox****************@TK2MSFTNGP12.phx.gbl...
Iam trying to read an xml file from a website and i get junk
characters. But
when i open the same file in browser
everything is fine.
here is the snippet of the code

WebRequest objRequest =
WebRequest.Create("http://www.xvdabc.com/order.xml");
WebResponse objResponse = objRequest.GetResponse();
StreamReader SR = new StreamReader(objResponse.GetResponseStream());
string strContent = oSR.ReadToEnd();
strContent has junk characters
TIA



Nov 16 '05 #5
SKG
Nicholas,
iam able to see the same file in the browser without any problem.
Does the browser has this decrypt algorithm build in. If so do i have to use
MSHTML components
to get the file?
Thanks!!!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
SKG,

I don't believe that the HttpWebResponse class understands how to handle compressed content. Because of this, you will have to run the stream
through an algorithm that will decompress the stream accoding to the x-gzip protocol.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
after GetResponse I found the response
object has followingproperties
ContentEncoding "x-gzip"
ContentType "text/xml" string
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
SKG,

What is the encoding of the stream that is being returned? You should specify the encoding to the StreamReader so that the bytes returned are encoded correctly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:Ox****************@TK2MSFTNGP12.phx.gbl...
> Iam trying to read an xml file from a website and i get junk characters. But
> when i open the same file in browser
> everything is fine.
> here is the snippet of the code
>
> WebRequest objRequest =
> WebRequest.Create("http://www.xvdabc.com/order.xml");
> WebResponse objResponse = objRequest.GetResponse();
> StreamReader SR = new StreamReader(objResponse.GetResponseStream()); > string strContent = oSR.ReadToEnd();
>
>
> strContent has junk characters
> TIA
>
>
>
>



Nov 16 '05 #6
SKG,

The browser does know how to interpret this. If you want to do it in
..NET, you can use the free Sharp Zip Library, located at (watch for line
wrap):

http://www.icsharpcode.net/OpenSourc...b/Default.aspx
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
Nicholas,
iam able to see the same file in the browser without any problem.
Does the browser has this decrypt algorithm build in. If so do i have to use MSHTML components
to get the file?
Thanks!!!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
SKG,

I don't believe that the HttpWebResponse class understands how to

handle
compressed content. Because of this, you will have to run the stream
through an algorithm that will decompress the stream accoding to the

x-gzip
protocol.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
after GetResponse I found the response
object has followingproperties
ContentEncoding "x-gzip"
ContentType "text/xml" string
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
wrote
in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
> SKG,
>
> What is the encoding of the stream that is being returned? You

should
> specify the encoding to the StreamReader so that the bytes returned

are > encoded correctly.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
> "SKG" <su***********@yahoo.com> wrote in message
> news:Ox****************@TK2MSFTNGP12.phx.gbl...
> > Iam trying to read an xml file from a website and i get junk

characters.
> But
> > when i open the same file in browser
> > everything is fine.
> > here is the snippet of the code
> >
> > WebRequest objRequest =
> > WebRequest.Create("http://www.xvdabc.com/order.xml");
> > WebResponse objResponse = objRequest.GetResponse();
> > StreamReader SR = new StreamReader(objResponse.GetResponseStream()); > > string strContent = oSR.ReadToEnd();
> >
> >
> > strContent has junk characters
> > TIA
> >
> >
> >
> >
>
>



Nov 16 '05 #7
SKG
Nicholas,

You are the MAN!!!!. Thanks it works!!!!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e5**************@TK2MSFTNGP10.phx.gbl...
SKG,

The browser does know how to interpret this. If you want to do it in
.NET, you can use the free Sharp Zip Library, located at (watch for line
wrap):

http://www.icsharpcode.net/OpenSourc...b/Default.aspx
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:Op**************@TK2MSFTNGP11.phx.gbl...
Nicholas,
iam able to see the same file in the browser without any problem.
Does the browser has this decrypt algorithm build in. If so do i have to

use
MSHTML components
to get the file?
Thanks!!!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
SKG,

I don't believe that the HttpWebResponse class understands how to

handle
compressed content. Because of this, you will have to run the stream
through an algorithm that will decompress the stream accoding to the

x-gzip
protocol.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SKG" <su***********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> after GetResponse I found the response
> object has followingproperties
> ContentEncoding "x-gzip"
> ContentType "text/xml" string
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
> message news:%2****************@TK2MSFTNGP10.phx.gbl...
> > SKG,
> >
> > What is the encoding of the stream that is being returned? You should
> > specify the encoding to the StreamReader so that the bytes
returned are
> > encoded correctly.
> >
> > Hope this helps.
> >
> >
> > --
> > - Nicholas Paldino [.NET/C# MVP]
> > - mv*@spam.guard.caspershouse.com
> >
> > "SKG" <su***********@yahoo.com> wrote in message
> > news:Ox****************@TK2MSFTNGP12.phx.gbl...
> > > Iam trying to read an xml file from a website and i get junk
characters.
> > But
> > > when i open the same file in browser
> > > everything is fine.
> > > here is the snippet of the code
> > >
> > > WebRequest objRequest =
> > > WebRequest.Create("http://www.xvdabc.com/order.xml");
> > > WebResponse objResponse = objRequest.GetResponse();
> > > StreamReader SR = new

StreamReader(objResponse.GetResponseStream());
> > > string strContent = oSR.ReadToEnd();
> > >
> > >
> > > strContent has junk characters
> > > TIA
> > >
> > >
> > >
> > >
> >
> >
>
>



Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ben Harper | last post by:
In VC7, look at the following code: char* ok1 = "1234567890ABCD"; char* ok2 = "1234567890ABCDE"; char* bad1 = "1234567890ABCDEF"; char* bad2 = "1234567890ABCDEFG"; string take; take = ok1;...
2
by: not aaron | last post by:
I start out with a string. Which I then encode with my own algorithm changing every characters ascii value depending on a key. I then save it to a binary file. When I generate the initial...
14
by: HB | last post by:
As many of us know, when we send legitimate emails to real customers from our apps, those emails often end up in the Hotmail (and MSN -- and AOL, too) junk folder. I've done a lot of testing with...
9
by: ThePants | last post by:
Hi, given the following code, I've been successful in grabbing pages for parsing, but for a certain page template (containing a particular piece of code) the stream always ends right after that...
6
by: Rainy | last post by:
Hi, I tried searching for this and did not find this issue. I only looked at about dozen hits, I apologize if this is covered somewhere and I missed it. Without much further ado, here's the...
4
by: Index | last post by:
Hi, I am trying to compare a char* with an unsigned char*.I have type cast the later to char*.Now the problem is, the unsigned char* is populated with recv() function over the socket and sometimes...
4
by: situ | last post by:
Hello all, i have a column in a table which stores tag lines which are usually less than 500 charecter. when we display the data through the browser some character display as "boxes" or junks....
1
by: srkumar | last post by:
Hi.. I am trying to replace junk characters. I could not find the junk characters.. need help on this... Input File: <aff id="aff2">Institute of Astronomy, Bulgariaóšö×èë</aff> Output File:...
1
by: ksrashmi | last post by:
Hi We have text box field users are copying the data from the word document and pasting into textbox . after saving which is generating some junk characters . every time when i click on...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.