Overthere
asked on
Read XML from Webpage
I want to read XML from a webpage and write it to a file. Here's what I have and all I get in the output file is [OBJECT]:
It doesn't save the contents of the page..
what am I doing wrong?? I want to save the contents of the page as a file...
Private Function Chkit()
Dim shWin As New ShellWindows
Dim ie As InternetExplorer
For Each ie In shWin
If ie.LocationURL = "http://www.somplace.com/somepage.asp" Then
MsgBox ("Found it")
Set fs = CreateObject("Scripting.Fi leSystemOb ject")
Set a = fs.CreateTextFile("c:\test file.txt", True)
a.writeline (ie.Document)
a.Close
vswi = 1
Exit For
Else
MsgBox ("Not found yet")
vswi = 0
End If
Next
If vswi = 1 Then
Chkit = 1
Else
Chkit = 0
End If
End Function
It doesn't save the contents of the page..
what am I doing wrong?? I want to save the contents of the page as a file...
Private Function Chkit()
Dim shWin As New ShellWindows
Dim ie As InternetExplorer
For Each ie In shWin
If ie.LocationURL = "http://www.somplace.com/somepage.asp" Then
MsgBox ("Found it")
Set fs = CreateObject("Scripting.Fi
Set a = fs.CreateTextFile("c:\test
a.writeline (ie.Document)
a.Close
vswi = 1
Exit For
Else
MsgBox ("Not found yet")
vswi = 0
End If
Next
If vswi = 1 Then
Chkit = 1
Else
Chkit = 0
End If
End Function
ASKER
Sorry it took so long to respond - got called away for a bit. Anyway I tried what you have above and I got the following:
Microsoft VBScript runtime error '800a0046'
Permission denied: 'MsgBox'
/myfolder/test3.asp, line 17
My page's line 17 is equivalent to your Call MsgBox... line above. I used my own specific webpage that has bunches of parameters to login with.
When I tried it using the http://www.google.com just as you have it above I still got the same error.
Microsoft VBScript runtime error '800a0046'
Permission denied: 'MsgBox'
/myfolder/test3.asp, line 17
My page's line 17 is equivalent to your Call MsgBox... line above. I used my own specific webpage that has bunches of parameters to login with.
When I tried it using the http://www.google.com just as you have it above I still got the same error.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got it to work with the google.com page, but when I place my specific webpage in there, I just get the Page cannot be found error message.
When I use the URL of the specific XML I want, the beginning URL is different than the resultant page. So I tell it something like this above in place of google:
https://www.mytestonlysite.com/login?username=GoodGirl&upwrd=MyPW&ticket=12345
This URL actually logs the user in and then routes to a page called XMLResults.asp where I see the XML displayed. This works if I just copy & paste the login direct to the address line of my browser and hit GO but when I add it to your coding above, I get page not found. Any further ideas?
When I use the URL of the specific XML I want, the beginning URL is different than the resultant page. So I tell it something like this above in place of google:
https://www.mytestonlysite.com/login?username=GoodGirl&upwrd=MyPW&ticket=12345
This URL actually logs the user in and then routes to a page called XMLResults.asp where I see the XML displayed. This works if I just copy & paste the login direct to the address line of my browser and hit GO but when I add it to your coding above, I get page not found. Any further ideas?
If the website is using the javascript to go to next page, XMLHttp won't take you there as it won't execute the Javascript. Show the ResponseText that you get from that URL.
ASKER
I can't get it to stop there. It wants to automatically go to the next page based on the info given. If I tried this same thing using JavaScript would that work?
Na as server side components don't execute the client side javascript. Show us the ResponseText and we might be able to find a way.
ASKER
I tried to get the ResponseText info by not sending the ticket info in the "GET" request. It does log me into the system and then I get the response which looks like it's just the detail for the successful login page. There are bunch of INCLUDES which may be where it then redirects to the page I need, but from what I see there is nothing that shows where it automatically goes to another page by passing the parameters. The text I receive just shows the page contents itself. I suppose I'll take a different approach if I can't get to it because it's redirecting.
If you show ur the ResponseText we might be able to figure that out. Still it won't gaurantee that you can do it but at least you could try.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I apologize for not being able to post what I get from the previous responses, but it's not in the best interest of either party that I disclose that coding...
So onward ho...
I've tried coding above and I get the following error:
URL Open Error, Cannot Find site or document
The webpage is open on my desktop and I can see the XML, but it is a page within a secure site and also within the cgi-bin folder. Would either of those characteristics pose a problem? For example the webpage I'm trying to get the XML from is called:
https://www.mytestsiteonly.com/cgi-bin/xmlinfo.asp (this is just an example - page doesn't exist)
So onward ho...
I've tried coding above and I get the following error:
URL Open Error, Cannot Find site or document
The webpage is open on my desktop and I can see the XML, but it is a page within a secure site and also within the cgi-bin folder. Would either of those characteristics pose a problem? For example the webpage I'm trying to get the XML from is called:
https://www.mytestsiteonly.com/cgi-bin/xmlinfo.asp (this is just an example - page doesn't exist)
ASKER
I was not able to resolve this question but am willing to split the points among those that responded. I actually gave this code back to the originators of the page that I was trying to capture and they couldn't get it to work either. amit_g received more points due to the fact that assistance was given for a longer time period. They honestly tried to help but the B grade was only because there really was no answer and definitely NOT a reflection of the ability.
Dim oXMLHttp
Set oXMLHttp = CreateObject("MSXML2.Serve
Call oXMLHttp.Open("GET", "http://www.google.com", False)
Call oXMLHttp.Send
Call MsgBox(oXMLHttp.ResponseTe
Set fs = CreateObject("Scripting.Fi
Set a = fs.CreateTextFile("c:\test
a.writeline (oXMLHttp.ResponseText)
a.Close
Set oXMLHttp = Nothing