parsing data returned from Microsoft.XMLHTTP 
April 14th, 2006, 02:45 AM
| | | parsing data returned from Microsoft.XMLHTTP
I used some code from another post to successfully search and retrieve data
from a web site. But now I have been pulling out my hair trying to take
informaiton out of the file and display it in my form. Here is my code:
Private Sub Command20_Click()
Dim msXML As Object
Dim strpageContent As String
Dim fh As Long
Dim strWebsite As String
Dim StartSearch As String
Dim EndSearch As String
Dim finishdoc As String
strWebsite = "http://www.autocheck.com/consumers/vinSearchAction.do?vin="
strWebsite = strWebsite & [VIN]
fh = FreeFile
Set msXML = CreateObject("Microsoft.XMLHTTP")
msXML.Open "GET", strWebsite, False
msXML.SetRequestHeader "Content-type", "text/xml"
msXML.send
strpageContent = msXML.responseText
'Search through strpageContent for the begining of <!--START VEHICLE
DESCRIPTION-->
'<!--END VEHICLE DESCRIPTION-->
Open "c:\temp\car_data_file.txt" For Output As #FreeFile
Print #fh, StartSearch
Set msXML = Nothing
Close #fh
End Sub
The data comes back like this, this is just the important stuff:
<!--START VEHICLE DESCRIPTION-->
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td class="sticky_text">
<br>
<strong>
Free VIN decode
</strong>
</td>
</tr>
<tr>
<td class="sticky_text">
<strong>
VIN:
</strong>
JHMCM56683C055422
</td>
</tr>
<tr>
<td class="sticky_text">
<strong>
Year:
</strong>
2003
</td>
</tr>
<tr>
<td class="sticky_text">
<strong>
Make:
</strong>
Honda
</td>
</tr>
<tr>
<td class="sticky_text">
<strong>
Model:
</strong>
Accord EX
</td>
</tr>
<tr>
<td class="sticky_text">
<strong>
Style/Body:
</strong>
Sedan 4 Door
</td>
</tr>
<tr>
<td class="sticky_text">
<strong>
Engine:
</strong>
MFI I-4 2.4L DOHC
</td>
</tr>
<tr>
<td class="sticky_text">
<strong>
Country of Assembly:
</strong>
Japan
<br>
</td>
</tr>
</table>
<!--END VEHICLE DESCRIPTION-->
I need to take the Year, make, model, and engine into text boxes on the form.
Any help would be appreciated. | 
April 14th, 2006, 11:25 AM
| | | Re: parsing data returned from Microsoft.XMLHTTP
csinva wrote:[color=blue]
> I used some code from another post to successfully search and retrieve data
> from a web site. But now I have been pulling out my hair trying to take
> informaiton out of the file and display it in my form. Here is my code:
>
> Private Sub Command20_Click()
>
> Dim msXML As Object
> Dim strpageContent As String
> Dim fh As Long
> Dim strWebsite As String
> Dim StartSearch As String
> Dim EndSearch As String
> Dim finishdoc As String
>
>
> strWebsite = "http://www.autocheck.com/consumers/vinSearchAction.do?vin="
> strWebsite = strWebsite & [VIN]
>
> fh = FreeFile
>
> Set msXML = CreateObject("Microsoft.XMLHTTP")
> msXML.Open "GET", strWebsite, False
> msXML.SetRequestHeader "Content-type", "text/xml"
> msXML.send
> strpageContent = msXML.responseText
>
> 'Search through strpageContent for the begining of <!--START VEHICLE
> DESCRIPTION-->
>
> '<!--END VEHICLE DESCRIPTION-->
>
> Open "c:\temp\car_data_file.txt" For Output As #FreeFile
> Print #fh, StartSearch
>
>
> Set msXML = Nothing
> Close #fh
>
> End Sub
>
> The data comes back like this, this is just the important stuff:
>
> <!--START VEHICLE DESCRIPTION-->
> <table cellpadding="3" cellspacing="0" border="0">
> <tr>
> <td class="sticky_text">
> <br>
>
> <strong>
> Free VIN decode
> </strong>
>
> </td>
> </tr>
> <tr>
> <td class="sticky_text">
>
> <strong>
> VIN:
> </strong>
> JHMCM56683C055422
> </td>
> </tr>
> <tr>
> <td class="sticky_text">
>
> <strong>
> Year:
> </strong>
> 2003
> </td>
> </tr>
> <tr>
> <td class="sticky_text">
>
> <strong>
> Make:
> </strong>
> Honda
> </td>
> </tr>
> <tr>
> <td class="sticky_text">
>
> <strong>
> Model:
> </strong>
> Accord EX
> </td>
> </tr>
> <tr>
> <td class="sticky_text">
>
> <strong>
> Style/Body:
> </strong>
> Sedan 4 Door
> </td>
> </tr>
> <tr>
> <td class="sticky_text">
>
> <strong>
> Engine:
> </strong>
> MFI I-4 2.4L DOHC
> </td>
> </tr>
> <tr>
> <td class="sticky_text">
>
> <strong>
> Country of Assembly:
> </strong>
> Japan
> <br>
> </td>
> </tr>
>
>
> </table>
> <!--END VEHICLE DESCRIPTION-->
>
> I need to take the Year, make, model, and engine into text boxes on the form.[/color]
I'm not going to write the code (somebody might), but I would start by
splitting the file into an array using Split(textInFile, "Year:").
Then I would iterate the array and filter out the tags. ex:
replace("<strong>", "") for each item.
Debug.print to see what you end up with.
From there it should be fairly simple to parse the make and model. | 
April 14th, 2006, 02:45 PM
| | | Re: parsing data returned from Microsoft.XMLHTTP
"csinva" <u20846@uwe> wrote in news:5ebe63b232ecc@uwe:
[color=blue]
> The data comes back like this, this is just the important stuff:
>
><!--START VEHICLE DESCRIPTION-->
> <table cellpadding="3" cellspacing="0" border="0">
> <tr>
> <td class="sticky_text">
> <br>
>
> <strong>
> Free VIN decode
> </strong>
>
> </td>
> </tr>
>[/color]
This isn't XML, but HTML.
If it were XML, then you could use ADO's XML drivers to parse it.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/ | 
April 14th, 2006, 02:55 PM
| | | Re: parsing data returned from Microsoft.XMLHTTP
On Fri, 14 Apr 2006 02:34:56 GMT, "csinva" <u20846@uwe> wrote:
I would not use XMLHTTP but rather the WebBrowser control. Then I can
use the DOM to get to what I want.
-Tom.
[color=blue]
>I used some code from another post to successfully search and retrieve data
>from a web site. But now I have been pulling out my hair trying to take
>informaiton out of the file and display it in my form. Here is my code:
>[/color]
<clip> | 
April 14th, 2006, 03:15 PM
| | | Re: parsing data returned from Microsoft.XMLHTTP
This will take some finer tuning but with what you sent us I was able
to do the following:
before you create the txt file do at least the following
1) change "Free VIN decode " to "cntl</td><td>cntlinfo"
2) change every occurance of ":" to "</td><td>"
3) instead of saving the file as txt save it as .html
4) you can then import that file into a table (once you fine tune a
couple of linebreaks that are in the first and last entries so that
they are not there.).
the field names are cntl and cntlinfo
And with the type of work you did to get here, I think you can take it
from there. It works like a charm.
Ron | 
April 14th, 2006, 03:25 PM
| | | Re: parsing data returned from Microsoft.XMLHTTP
All you need to have it think it is html is the <table> thru the
</table> and then save it as html | 
April 20th, 2006, 01:35 AM
| | | Re: parsing data returned from Microsoft.XMLHTTP
Could you elaborate on the WebBrowser control?
Tom van Stiphout wrote:[color=blue]
>I would not use XMLHTTP but rather the WebBrowser control. Then I can
>use the DOM to get to what I want.
>
>-Tom.
>[color=green]
>>I used some code from another post to successfully search and retrieve data
>>from a web site. But now I have been pulling out my hair trying to take
>>informaiton out of the file and display it in my form. Here is my code:[/color]
>
><clip>[/color]
--
Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/200604/1 | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,989 network members.
|