471,573 Members | 1,323 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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>&nbsp;

<strong>
Free VIN decode
</strong>

</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
VIN:
</strong>
JHMCM56683C055422
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Year:
</strong>
2003
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Make:
</strong>
Honda
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Model:
</strong>
Accord EX
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Style/Body:
</strong>
Sedan 4 Door
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Engine:
</strong>
MFI I-4 2.4L DOHC
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<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.
Apr 14 '06 #1
6 9943
rkc
csinva wrote:
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>&nbsp;

<strong>
Free VIN decode
</strong>

</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
VIN:
</strong>
JHMCM56683C055422
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Year:
</strong>
2003
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Make:
</strong>
Honda
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Model:
</strong>
Accord EX
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Style/Body:
</strong>
Sedan 4 Door
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<strong>
Engine:
</strong>
MFI I-4 2.4L DOHC
</td>
</tr>
<tr>
<td class="sticky_text">
&nbsp;
<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.


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.
Apr 14 '06 #2
"csinva" <u20846@uwe> wrote in news:5ebe63b232ecc@uwe:
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>&nbsp;

<strong>
Free VIN decode
</strong>

</td>
</tr>


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/
Apr 14 '06 #3
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.

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:

<clip>

Apr 14 '06 #4
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

Apr 14 '06 #5
All you need to have it think it is html is the <table> thru the
</table> and then save it as html

Apr 14 '06 #6
Could you elaborate on the WebBrowser control?

Tom van Stiphout wrote:
I would not use XMLHTTP but rather the WebBrowser control. Then I can
use the DOM to get to what I want.

-Tom.
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:


<clip>


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200604/1
Apr 20 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by TheFarSeer | last post: by
1 post views Thread by danep | last post: by
1 post views Thread by avpkills2002 | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

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.