473,402 Members | 2,050 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,402 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 10062
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: 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...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.