Bow Wow Dubs!
Say hello to Dubs. He is the 11th Alaskan Malamute to serve as the University of Washington's mascot.
DBpedia suggests that the colors of an Alaskan Malamute are:
Can you harvest the color of the Alaskan Malamute from DBpedia and put it in the orange box on this very page? The effect would look like this:
Greasemonkey
Since you are going to modify this page (i.e., not one of your own web pages), you will need to write a Greasemonkey script that fires when your Firefox browser hits this web page: "http://projects.ischool.washington.edu/tabrooks/343INFOAutumn11/sparqlHuskies.htm"
GM_xmlhttpRequest
GM_xmlhttpRequest({ method: 'GET', url: 'URL of requested page here', headers: { 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey', 'Accept': 'text/html', }, onload: function(responseDetails) { // stuff is of string type var stuff = responseDetails.responseText; } });
DBpedia portal for SQARQL queries
http://dbpedia.org/sparql
A SPARQL query
Color of Alaskan Malamutes
SELECT ?color WHERE { <http://dbpedia.org/resource/Alaskan_Malamute> <http://dbpedia.org/property/color> ?color . }
Payload
The SPARQL query above - Color of Alaskan Malamutes - gives the following payload:
<table class="sparql" border="1"> <tr> <th>color</th> </tr> <tr> <td>Gray, sable, black, or red, always with white, as well as all white</td> </tr> </table>
XPath
The following XPath will target the single <td> element where the color resides. Note that the variable "td" is a nodelist.
var newDiv = document.createElement("div"); newDiv.innerHTML = responseDetails.responseText; var td = document.evaluate('//td', newDiv, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
You can complete the rest of the assignment by targeting the "colorDiv" and putting information there.