473,379 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 10059
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MikeO | last post by:
I need to create a web client code in C# that retrieves data from a web site in sync method. I have the following code in VB script that works today but need to be converted to c# Set xmlHttp =...
3
by: TheFarSeer | last post by:
Hi, i have a server that recieves data often from a third party data provider often. I would like to PUSH this data to the client webpage, WITHOUT having to force the user to hit refresh or...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
6
by: mihirnmehta | last post by:
This is my code function getDetails() { var name = document.getElementById("movie_name").value; if (window.XMLHttpRequest) //For Mozilla Browsers { XMLHttp=new XMLHttpRequest() }
1
by: danep | last post by:
Hi, I'm fairly new to AJAX, but I've been able to retrieve HTML and plain-text documents without any trouble. However, I haven't figured out how to retrieve it in XML format. Basically, here's...
0
by: BlipBlip | last post by:
Hi All, I was not sure which forum to post the message to since the problem related to ASP/AJAX, but decided to post it here. I have a simple routine which utilizes an Ajax to query database for...
5
by: perhapscwk | last post by:
I want to use ajax, by selected the option box, retrieve data from a .xml file and fill in to the textbox. below is the html page <script src="selectcd.js"></script> <form> Select a CD:...
1
by: avpkills2002 | last post by:
I seem to be getting this weird problem in Internet explorer. I have written a code for parsing a XML file and displaying the output. The code works perfectly fine with ffx(Firefox).However is not...
1
by: fidgen | last post by:
Hiya, I'm trying to get a AJAX driven update to my list of news articles, so when users click the title of the news article, it pops up the article content in a thickbox overlay. Retrieving...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.