Importing Web XML data

MrLookout9

New Member
Joined
Jun 25, 2011
Messages
27
MrExcel has never let me down before...
The vision: I keep a list of all the movies I've seen. I'd like to import some data about each movie.

I have found several sources that provide data in a web XML format. For instance, http://www.omdbapi.com/?s=American History X&r=XML.

What I’d like to do is grab the imdbID for each movie in my list. All movies are in column A. I’d like to have the imdbID in column B.

I am open to other approaches/ data sources.

Thank you!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You could open the XML in some empty sheet using
Code:
    ActiveWorkbook.XmlImport URL:= _
        "http://www.omdbapi.com/?s=American History X&r=XML", ImportMap:=Nothing, _
        Overwrite:=True, Destination:=Range("$A$1")
Then use VLOOKUP to fetch the imdbID using the movie title as the search argument

[TABLE="width: 68"]
<tbody>[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 68"]
<tbody>[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Yes I do. You could create a function that uses movie title as an argument and use "http://www.omdbapi.com/?t=" & movieTitle
and use xpath to retrieve the imdbID node so you will only have to copy the formula with the custom function to your 400 rows and voila
 
Upvote 0
I can do more than that here is a Excel 2013 workbook with what you need
https://dl.dropboxusercontent.com/u/23094164/movies.imdbID.xlsx
I hope it helps

Col A has movies titles
Col B has WEBSERVICE(" http://www.omdbapi.com/?t="&A2)
Col C has FILTERXML but is not working with JSON so I used FIND
Col D has =MID(B2;FIND("imdbID";B2)+9;9)

To do the same for Excel 2010 and below can be done to with some work
Sergio
 
Last edited:
Upvote 0
Hi Sergio, this looks great. Unfortunately I am working with Excel 2010. Did you define these functions in VBA or are the standard with 2013? I opened up Visual Basic and didn't see any code. Again, thank you for your help.
 
Upvote 0
Here it is the file for Excel 2010
https://dl.dropboxusercontent.com/u/23094164/movies.imdbIDforexcel2010.xlsm
And here it is the function that runs instead of WEBSERVICE()
Code:
Function getHtmlFromUrl(pURL As String) As String
    Dim resText As String
    Dim objHttp As Object
    Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
    objHttp.Open "GET", pURL, False
    objHttp.Send ""
    getHtmlFromUrl = objHttp.ResponseText
End Function
It my pleasure to help
Sergio
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top