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!
 
sergioMabres
user-offline.png

Of course you are great and many many many thanks from me.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Here is the final answer for kocir problem
Hoja1

*CDEFGHIJKL
productUrlnameminpriceminpriceshoptutty.czAlza.czMALL.czT.S.Bohemia a.s.CZC.czKASA.cz
**********
http://gps-navigace.heureka.cz/mio-combo-5107u-lifetime/Mio Combo 5107u LifetimeNakupka.czneprodáváneprodáváneprodáváneprodáváneprodává
http://gps-navigace.heureka.cz/mio-combo-5107u-lifetime/Mio Combo 5107u LifetimeNakupka.czneprodává

<tbody>
[TD="bgcolor: #cacaca, align: center"]1[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]

[TD="align: right"]4340[/TD]

[TD="align: right"]4990[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]

[TD="align: right"]4340[/TD]

[TD="align: right"]4990[/TD]
[TD="align: right"]4790[/TD]
[TD="align: right"]4599[/TD]

[TD="align: right"]4790[/TD]
[TD="align: right"]4790[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
C2=HYPERLINK(IFERROR(FILTERXML($B2,"//div[@id='productUrl']"),""))
D2=IFERROR(FILTERXML($B2,"//div[@id='name']"),"")
E2=IFERROR(FILTERXML($B2,"//div[@id='minprice']"),"")
F2=IFERROR(FILTERXML($B2,"//div[@id='minpriceshop']"),"")
G2=IF($F2<>"",IFERROR(FILTERXML($B2,"//div[@id='offers']//div[@id='"&G$1&"']"),"neprodává"),"")
C3=(MID($B3,FIND("id="""&C$1,$B3,1)+LEN(C$1)+6,FIND("",$B3,FIND("id="""&C$1,$B3,1))-FIND("id="""&C$1,$B3,1)-(LEN(C$1)+6)))
D3=(MID($B3,FIND("id="""&D$1,$B3,1)+LEN(D$1)+6,FIND("",$B3,FIND("id="""&D$1,$B3,1))-FIND("id="""&D$1,$B3,1)-(LEN(D$1)+6)))
E3=VALUE(MID($B3,FIND("id="""&E$1,$B3,1)+LEN(E$1)+6,FIND("",$B3,FIND("id="""&E$1,$B3,1))-FIND("id="""&E$1,$B3,1)-(LEN(E$1)+6)))
F3=(MID($B3,FIND("id="""&F$1,$B3,1)+LEN(F$1)+6,FIND("",$B3,FIND("id="""&F$1,$B3,1))-FIND("id="""&F$1,$B3,1)-(LEN(F$1)+6)))
G3=IF($F3<>"",IFERROR(VALUE(MID($B3,FIND("id="""&G$1,$B3,FIND("id=""offers",$B3,1))+14,FIND("",$B3,FIND("id="""&G$1,$B3,FIND("id=""offers",$B3,1)))-FIND("id="""&G$1,$B3,FIND("id=""offers",$B3,1))-14)),"neprodává"),"")
H3=IF($F3<>"",IFERROR(FILTERXML($B3,"//div[@id='offers']//div[@id='"&H$1&"']"),"neprodává"),"")
I3=IF($F3<>"",IFERROR(FILTERXML($B3,"//div[@id='offers']//div[@id='"&I$1&"']"),"neprodává"),"")
J3=IF($F3<>"",IFERROR(FILTERXML($B3,"//div[@id='offers']//div[@id='"&J$1&"']"),"neprodává"),"")
K3=IF($F3<>"",IFERROR(FILTERXML($B3,"//div[@id='offers']//div[@id='"&K$1&"']"),"neprodává"),"")
L3=IF($F3<>"",IFERROR(FILTERXML($B3,"//div[@id='offers']//div[@id='"&L$1&"']"),"neprodává"),"")
C4=(MID($B4,FIND("id="""&C$1,$B4,1)+LEN(C$1)+6,FIND("",$B4,FIND("id="""&C$1,$B4,1))-FIND("id="""&C$1,$B4,1)-(LEN(C$1)+6)))
D4=(MID($B4,FIND("id="""&D$1,$B4,1)+LEN(D$1)+6,FIND("",$B4,FIND("id="""&D$1,$B4,1))-FIND("id="""&D$1,$B4,1)-(LEN(D$1)+6)))
E4=VALUE(MID($B4,FIND("id="""&E$1,$B4,1)+LEN(E$1)+6,FIND("",$B4,FIND("id="""&E$1,$B4,1))-FIND("id="""&E$1,$B4,1)-(LEN(E$1)+6)))
F4=(MID($B4,FIND("id="""&F$1,$B4,1)+LEN(F$1)+6,FIND("",$B4,FIND("id="""&F$1,$B4,1))-FIND("id="""&F$1,$B4,1)-(LEN(F$1)+6)))
G4=IF($F4<>"",IFERROR(VALUE(MID($B4,FIND("id="""&G$1,$B4,FIND("id=""offers",$B4,1))+14,FIND("",$B4,FIND("id="""&G$1,$B4,FIND("id=""offers",$B4,1)))-FIND("id="""&G$1,$B4,FIND("id=""offers",$B4,1))-14)),"neprodává"),"")
H4=IF($F4<>"",IFERROR(VALUE(MID($B4,FIND("id="""&H$1,$B4,FIND("id=""offers",$B4,1))+LEN(H$1)+6,FIND("",$B4,FIND("id="""&H$1,$B4,FIND("id=""offers",$B4,1)))-FIND("id="""&H$1,$B4,FIND("id=""offers",$B4,1))-(LEN(H$1)+6))),"neprodává"),"")
I4=IF($F4<>"",IFERROR(VALUE(MID($B4,FIND("id="""&I$1,$B4,FIND("id=""offers",$B4,1))+LEN(I$1)+6,FIND("",$B4,FIND("id="""&I$1,$B4,FIND("id=""offers",$B4,1)))-FIND("id="""&I$1,$B4,FIND("id=""offers",$B4,1))-(LEN(I$1)+6))),"neprodává"),"")
J4=IF($F4<>"",IFERROR(VALUE(MID($B4,FIND("id="""&J$1,$B4,FIND("id=""offers",$B4,1))+LEN(J$1)+6,FIND("",$B4,FIND("id="""&J$1,$B4,FIND("id=""offers",$B4,1)))-FIND("id="""&J$1,$B4,FIND("id=""offers",$B4,1))-(LEN(J$1)+6))),"neprodává"),"")
K4=IF($F4<>"",IFERROR(VALUE(MID($B4,FIND("id="""&K$1,$B4,FIND("id=""offers",$B4,1))+LEN(K$1)+6,FIND("",$B4,FIND("id="""&K$1,$B4,FIND("id=""offers",$B4,1)))-FIND("id="""&K$1,$B4,FIND("id=""offers",$B4,1))-(LEN(K$1)+6))),"neprodává"),"")
L4=IF($F4<>"",IFERROR(VALUE(MID($B4,FIND("id="""&L$1,$B4,FIND("id=""offers",$B4,1))+LEN(L$1)+6,FIND("",$B4,FIND("id="""&L$1,$B4,FIND("id=""offers",$B4,1)))-FIND("id="""&L$1,$B4,FIND("id=""offers",$B4,1))-(LEN(L$1)+6))),"neprodává"),"")

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

These formulas are to replace FILTERXML in Office 2007 using FIND and MID
Cheers
Sergio
 
Upvote 0
It works very well. Just one small a problem.


When ActiveCell.FormulaR1C1 = getHtmlFromUrl("http://"www.mypage.com") insert result string to active cell, than the text is wraped and row become too outstretched. I tried to format cell as "text" by rightclick of mouse before launching the macro, but after running the macro the cell shows ###################### of course the text inside of cell is still ok. I have to go to another cell and copy format to force the cell to show real text.

Any help?

I do no like to use this "Wrap Text" to unwrap text in the cell or copy/paste format from another cell.
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
 
Upvote 0
I know way Excel shows ###. I do not undarstand why Excel is using wrapimg for the result of the formula, because it was not applied for result of WEBSERVICE formula.

Anyway I solve it by this way:

ActiveCell.NumberFormat = "@"
ActiveCell.FormulaR1C1 = getHtmlFromUrl(www.mypages.com)
With Selection
.WrapText = False
.NumberFormat = "General"
End With

Maybe it is not "clean solution", but it works and cells are not "jumping" in size when the macro runs. :) Thanks this solution, the text is readable (NumberFormat = "General") and not wraped (WrapText = False).
 
Upvote 0
Sometimes =WEBSERVICE ("www.mypages.com") does not return html code, but #VALUE! .I d like to check the returned result but there is a problem with mitchmatch of formats and everytime I got error #NAME!

Is there any solution how to check if returned result is OK or not.?


myHTMLcheck = Mid(Selection.Value, 4, 4) ' The error message in my language is "#HODNOTA!"
If myHTMLcheck <> "html" Then MsgBox Mid(Selection.Value, 4, 4) ' string "html" is part of correct result
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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