By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,932 Members | 1,547 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,932 IT Pros & Developers. It's quick & easy.

Capturing XML pages from Server

P: n/a
Hello all:

Again, let me thank everyone who has helped in the past. Can't wait till I
can help out with some advice of my own.

Now, I am building an app that wishes to retrieve the output of Google
Desktop. It is very simple, I wish to send an http request asking for the
results in XML. ( by adding &format=xml to the end of the url) i would like
to capture the response from the Google Desktop server, (on the local
machine) and save that file into memory, then write a text file from one of
the fields in the document like so:

Dim myDoc as xmldocument
Dim ofile as io.file
Dim owriter as streamwriter = ofile.createtext(pathtotextfile)
owriter.writeline(myDoc.documentelement.childnodes (0).childnodes(3).innertext.tostring())
owriter.flush()
My problem is getting the myDoc. I am unsure of how to 'capture' the
response from the server. In the first version, I was forced to call ie and
navigate, then use the WSHShell.SendKeys() method to send an ALT, then DOWN,
DOWN,DOWN, DOWN, DOWN, ENTER,filename,Enter. This process is stupid, I
know, but the only thing i could figure out in my allotted time period. So
this method saved the xml document to disk, then I used a separate program
to open those files from disk, and perform the text-file writing.

So am I really far off by looking at the System.Web.dll? I was looking at
the HTTPResponse Class and the HTTPRequest Class, and thier associated help
in the MSDN library, but I am unsure of how to implement these classes to
accomplish my task.

Thanks ever so much.

Steve


Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Look at the system.net.httpwebrequest & system.net.httpwebresponse objects
I use vb.net so

<untested code -- I'm unsure where the new keyword actually goes and all
that >
dim x as new system.net.httpwebrequest
dim y as system.net.httpwebresponse = x.getresponse(GOOGLE URL)

I'm not sure if this would work, but why not?

"Steve Wolfie" <st*********@community.nospam> wrote in message
news:OG**************@TK2MSFTNGP14.phx.gbl...
Hello all:

Again, let me thank everyone who has helped in the past. Can't wait till I can help out with some advice of my own.

Now, I am building an app that wishes to retrieve the output of Google
Desktop. It is very simple, I wish to send an http request asking for the
results in XML. ( by adding &format=xml to the end of the url) i would like to capture the response from the Google Desktop server, (on the local
machine) and save that file into memory, then write a text file from one of the fields in the document like so:

Dim myDoc as xmldocument
Dim ofile as io.file
Dim owriter as streamwriter = ofile.createtext(pathtotextfile)
owriter.writeline(myDoc.documentelement.childnodes (0).childnodes(3).innertex
t.tostring()) owriter.flush()
My problem is getting the myDoc. I am unsure of how to 'capture' the
response from the server. In the first version, I was forced to call ie and navigate, then use the WSHShell.SendKeys() method to send an ALT, then DOWN, DOWN,DOWN, DOWN, DOWN, ENTER,filename,Enter. This process is stupid, I
know, but the only thing i could figure out in my allotted time period. So this method saved the xml document to disk, then I used a separate program
to open those files from disk, and perform the text-file writing.

So am I really far off by looking at the System.Web.dll? I was looking at
the HTTPResponse Class and the HTTPRequest Class, and thier associated help in the MSDN library, but I am unsure of how to implement these classes to
accomplish my task.

Thanks ever so much.

Steve

Nov 19 '05 #2

P: n/a
Thanks for Clamps's informative inputs.

Hi Steve,

For the quesiton you mentioned, I think HttpWebRequest/HttpWebResposne will
be the reasonable choice. WE can use the HttpWebRequest to send get/post
request to the remote web resource and then read teh content from the
HttpWebResponse's ResponseStream. If the response content is really XML
format, we can use XmlDocumetn.Load method to load content from the web
request's responseStream. Something like:

HttpWebRequest req =
WebRequest.Create("http://servername/appname/resource.res") as
HttpWebRequest;

HttpWebResponse rep = req.GetResponse() as HttpWebResponse;

Stream stream = rep.GetResponseStream();

XmlDocument doc = new XmlDocument();

doc.Load(stream);

.......

Please feel free to post here if you have anything unclear or further
question.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Clamps" <Cl****@Spamless.com>
| References: <OG**************@TK2MSFTNGP14.phx.gbl>
| Subject: Re: Capturing XML pages from Server
| Date: Wed, 3 Aug 2005 16:21:04 -0500
| Lines: 64
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
| Message-ID: <#y**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: state.al.us 216.226.180.1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:115983
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Look at the system.net.httpwebrequest & system.net.httpwebresponse objects
| I use vb.net so
|
| <untested code -- I'm unsure where the new keyword actually goes and all
| that >
| dim x as new system.net.httpwebrequest
| dim y as system.net.httpwebresponse = x.getresponse(GOOGLE URL)
|
| I'm not sure if this would work, but why not?
|
|
|
| "Steve Wolfie" <st*********@community.nospam> wrote in message
| news:OG**************@TK2MSFTNGP14.phx.gbl...
| > Hello all:
| >
| > Again, let me thank everyone who has helped in the past. Can't wait
till
| I
| > can help out with some advice of my own.
| >
| > Now, I am building an app that wishes to retrieve the output of Google
| > Desktop. It is very simple, I wish to send an http request asking for
the
| > results in XML. ( by adding &format=xml to the end of the url) i would
| like
| > to capture the response from the Google Desktop server, (on the local
| > machine) and save that file into memory, then write a text file from one
| of
| > the fields in the document like so:
| >
| > Dim myDoc as xmldocument
| > Dim ofile as io.file
| > Dim owriter as streamwriter = ofile.createtext(pathtotextfile)
| >
|
owriter.writeline(myDoc.documentelement.childnodes (0).childnodes(3).innertex
| t.tostring())
| > owriter.flush()
| >
| >
| > My problem is getting the myDoc. I am unsure of how to 'capture' the
| > response from the server. In the first version, I was forced to call ie
| and
| > navigate, then use the WSHShell.SendKeys() method to send an ALT, then
| DOWN,
| > DOWN,DOWN, DOWN, DOWN, ENTER,filename,Enter. This process is stupid, I
| > know, but the only thing i could figure out in my allotted time period.
| So
| > this method saved the xml document to disk, then I used a separate
program
| > to open those files from disk, and perform the text-file writing.
| >
| > So am I really far off by looking at the System.Web.dll? I was looking
at
| > the HTTPResponse Class and the HTTPRequest Class, and thier associated
| help
| > in the MSDN library, but I am unsure of how to implement these classes
to
| > accomplish my task.
| >
| > Thanks ever so much.
| >
| > Steve
| >
| >
| >
| >
|
|
|

Nov 19 '05 #3

P: n/a
WOW!!! THANKS!!!

It works beautifully. Thank you so much for the help!!

Steve
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGXA01.phx.gbl...
Thanks for Clamps's informative inputs.

Hi Steve,

For the quesiton you mentioned, I think HttpWebRequest/HttpWebResposne
will
be the reasonable choice. WE can use the HttpWebRequest to send get/post
request to the remote web resource and then read teh content from the
HttpWebResponse's ResponseStream. If the response content is really XML
format, we can use XmlDocumetn.Load method to load content from the web
request's responseStream. Something like:

HttpWebRequest req =
WebRequest.Create("http://servername/appname/resource.res") as
HttpWebRequest;

HttpWebResponse rep = req.GetResponse() as HttpWebResponse;

Stream stream = rep.GetResponseStream();

XmlDocument doc = new XmlDocument();

doc.Load(stream);

......

Please feel free to post here if you have anything unclear or further
question.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Clamps" <Cl****@Spamless.com>
| References: <OG**************@TK2MSFTNGP14.phx.gbl>
| Subject: Re: Capturing XML pages from Server
| Date: Wed, 3 Aug 2005 16:21:04 -0500
| Lines: 64
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
| Message-ID: <#y**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: state.al.us 216.226.180.1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:115983
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Look at the system.net.httpwebrequest & system.net.httpwebresponse
objects
| I use vb.net so
|
| <untested code -- I'm unsure where the new keyword actually goes and all
| that >
| dim x as new system.net.httpwebrequest
| dim y as system.net.httpwebresponse = x.getresponse(GOOGLE URL)
|
| I'm not sure if this would work, but why not?
|
|
|
| "Steve Wolfie" <st*********@community.nospam> wrote in message
| news:OG**************@TK2MSFTNGP14.phx.gbl...
| > Hello all:
| >
| > Again, let me thank everyone who has helped in the past. Can't wait
till
| I
| > can help out with some advice of my own.
| >
| > Now, I am building an app that wishes to retrieve the output of Google
| > Desktop. It is very simple, I wish to send an http request asking for
the
| > results in XML. ( by adding &format=xml to the end of the url) i would
| like
| > to capture the response from the Google Desktop server, (on the local
| > machine) and save that file into memory, then write a text file from
one
| of
| > the fields in the document like so:
| >
| > Dim myDoc as xmldocument
| > Dim ofile as io.file
| > Dim owriter as streamwriter = ofile.createtext(pathtotextfile)
| >
|
owriter.writeline(myDoc.documentelement.childnodes (0).childnodes(3).innertex
| t.tostring())
| > owriter.flush()
| >
| >
| > My problem is getting the myDoc. I am unsure of how to 'capture' the
| > response from the server. In the first version, I was forced to call
ie
| and
| > navigate, then use the WSHShell.SendKeys() method to send an ALT, then
| DOWN,
| > DOWN,DOWN, DOWN, DOWN, ENTER,filename,Enter. This process is stupid,
I
| > know, but the only thing i could figure out in my allotted time
period.
| So
| > this method saved the xml document to disk, then I used a separate
program
| > to open those files from disk, and perform the text-file writing.
| >
| > So am I really far off by looking at the System.Web.dll? I was
looking
at
| > the HTTPResponse Class and the HTTPRequest Class, and thier associated
| help
| > in the MSDN library, but I am unsure of how to implement these classes
to
| > accomplish my task.
| >
| > Thanks ever so much.
| >
| > Steve
| >
| >
| >
| >
|
|
|

Nov 19 '05 #4

P: n/a
Thanks for your response and glad that it's of assistance. :-)

Good luck !

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Steve Wolfie" <st*********@community.nospam>
| References: <OG**************@TK2MSFTNGP14.phx.gbl>
<#y**************@tk2msftngp13.phx.gbl>
<#T**************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Capturing XML pages from Server
| Date: Thu, 4 Aug 2005 11:06:53 -0700
| Lines: 140
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1433
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1433
| X-RFC2646: Format=Flowed; Original
| Message-ID: <#$**************@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 65-112-167-178.dia.cust.qwest.net 65.112.167.178
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:116207
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| WOW!!! THANKS!!!
|
| It works beautifully. Thank you so much for the help!!
|
| Steve
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:%2****************@TK2MSFTNGXA01.phx.gbl...
| > Thanks for Clamps's informative inputs.
| >
| > Hi Steve,
| >
| > For the quesiton you mentioned, I think HttpWebRequest/HttpWebResposne
| > will
| > be the reasonable choice. WE can use the HttpWebRequest to send get/post
| > request to the remote web resource and then read teh content from the
| > HttpWebResponse's ResponseStream. If the response content is really XML
| > format, we can use XmlDocumetn.Load method to load content from the web
| > request's responseStream. Something like:
| >
| > HttpWebRequest req =
| > WebRequest.Create("http://servername/appname/resource.res") as
| > HttpWebRequest;
| >
| > HttpWebResponse rep = req.GetResponse() as HttpWebResponse;
| >
| > Stream stream = rep.GetResponseStream();
| >
| > XmlDocument doc = new XmlDocument();
| >
| > doc.Load(stream);
| >
| > ......
| >
| > Please feel free to post here if you have anything unclear or further
| > question.
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | From: "Clamps" <Cl****@Spamless.com>
| > | References: <OG**************@TK2MSFTNGP14.phx.gbl>
| > | Subject: Re: Capturing XML pages from Server
| > | Date: Wed, 3 Aug 2005 16:21:04 -0500
| > | Lines: 64
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
| > | Message-ID: <#y**************@tk2msftngp13.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: state.al.us 216.226.180.1
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:115983
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Look at the system.net.httpwebrequest & system.net.httpwebresponse
| > objects
| > | I use vb.net so
| > |
| > | <untested code -- I'm unsure where the new keyword actually goes and
all
| > | that >
| > | dim x as new system.net.httpwebrequest
| > | dim y as system.net.httpwebresponse = x.getresponse(GOOGLE URL)
| > |
| > | I'm not sure if this would work, but why not?
| > |
| > |
| > |
| > | "Steve Wolfie" <st*********@community.nospam> wrote in message
| > | news:OG**************@TK2MSFTNGP14.phx.gbl...
| > | > Hello all:
| > | >
| > | > Again, let me thank everyone who has helped in the past. Can't wait
| > till
| > | I
| > | > can help out with some advice of my own.
| > | >
| > | > Now, I am building an app that wishes to retrieve the output of
Google
| > | > Desktop. It is very simple, I wish to send an http request asking
for
| > the
| > | > results in XML. ( by adding &format=xml to the end of the url) i
would
| > | like
| > | > to capture the response from the Google Desktop server, (on the
local
| > | > machine) and save that file into memory, then write a text file
from
| > one
| > | of
| > | > the fields in the document like so:
| > | >
| > | > Dim myDoc as xmldocument
| > | > Dim ofile as io.file
| > | > Dim owriter as streamwriter = ofile.createtext(pathtotextfile)
| > | >
| > |
| >
owriter.writeline(myDoc.documentelement.childnodes (0).childnodes(3).innertex
| > | t.tostring())
| > | > owriter.flush()
| > | >
| > | >
| > | > My problem is getting the myDoc. I am unsure of how to 'capture'
the
| > | > response from the server. In the first version, I was forced to
call
| > ie
| > | and
| > | > navigate, then use the WSHShell.SendKeys() method to send an ALT,
then
| > | DOWN,
| > | > DOWN,DOWN, DOWN, DOWN, ENTER,filename,Enter. This process is
stupid,
| > I
| > | > know, but the only thing i could figure out in my allotted time
| > period.
| > | So
| > | > this method saved the xml document to disk, then I used a separate
| > program
| > | > to open those files from disk, and perform the text-file writing.
| > | >
| > | > So am I really far off by looking at the System.Web.dll? I was
| > looking
| > at
| > | > the HTTPResponse Class and the HTTPRequest Class, and thier
associated
| > | help
| > | > in the MSDN library, but I am unsure of how to implement these
classes
| > to
| > | > accomplish my task.
| > | >
| > | > Thanks ever so much.
| > | >
| > | > Steve
| > | >
| > | >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.