View Full Version : Help Using an API
I hope this is not too broad a question or in the wrong section. I am taking a class that has flown through a bunch of topics in a way that has left me with a very limited understanding of most of them so I'll be the first to admit that I don't know what I'm doing.
11-20-2012, 04:55 AM
when a board game is searched for, it returns an XML document that looks like this (http://www.boardgamegeek.com/xmlapi/boardgame/35424,2860) and I need to know how I would access these elements in a way that would allow me to use them on my own site
Where xmlDoc is the returned object:
var games = xmlDoc.getElementsByTagName( 'boardgame' ); should get you a table of <boardgame> elements.
Their attributes ( I don't mean their child elements ) won't be readable directly, you must use getAttribute.
11-20-2012, 06:09 AM
Ummm...but what is missing here is *HOW* you will get the given XML data to *YOUR* computer.
So normally there are two ways to do this:
(1) Do it in server-side code. PHP or JSP or ASP or whatever.
(2) Create a "proxy server" on your own server that gets a request from your own JS code (presumably an AJAX call) and uses the information in that request to simply go to the foreign server, retrieve the XML stream, and send it back to your JS code.
In either case, you need something server-side to accomplish this.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.