Capturing XML pages from Server

S

Steve Wolfie

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
 
C

Clamps

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?
 
S

Steven Cheng[MSFT]

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" <[email protected]>
| References: <[email protected]>
| 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: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: state.al.us 216.226.180.1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.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?
|
|
|
| | > 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
| >
| >
| >
| >
|
|
|
 
S

Steve Wolfie

WOW!!! THANKS!!!

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

Steve
 
S

Steven Cheng[MSFT]

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" <[email protected]>
| References: <[email protected]>
<#[email protected]>
<#[email protected]>
| 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: <#[email protected]>
| 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!TK2MSFTNGP15.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
| | > 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" <[email protected]>
| > | References: <[email protected]>
| > | 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: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: state.al.us 216.226.180.1
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.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?
| > |
| > |
| > |
| > | | > | > 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
| > | >
| > | >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top