| Introduction: | The bibliography service has now been extended to provide the information in XML. In this assignment, PHP5's SimpleXML implementation
is used to extract information from the XML. Now it becomes possible to build a service which not only is build aroundthe data provided by the query service, but selectively reuses parts of it to provide links to related information provided by 3rd party services. |
|---|---|
| Resources: | Simple Bibliography Search Service (delivering HTML or XML) PHP SimpleXML Web and XML Glossary (example entry) Google Scholar (example entry) |
| Instructions: |
Using the updated Simple Bibliography Search Service (delivering HTML or XML), it is now possible to request XML instead of HTML. Using the SimpleXML extension of PHP5 (remember that you must go through <ul>
<?php
include "Snoopy.class.php";
$snoopy = new Snoopy;
import_request_variables("g", "formval_") ;
$snoopy->fetch("http://dret.net/lectures/services-fall06/a/4/query.php?format=xml&author=" . urlencode($formval_author));
$xml = new SimpleXMLElement($snoopy->results);
foreach ($xml->xpath('//title[@type = "sharef:primaryTitle"]') as $title) {
echo '<li>' , $title , '</li>'; }
?>
</ul>
You are not required to add anything else but the title in the output of the service, because some of the XML would have to be processed in a non-trivial way to produce nicely looking output (but some information is easily accessible, such as the date information or links to resources, simply look at the XML if you would like to find out more). The above code retrieves XML and produces an HTML list of the titles. In this assignment, you now have to use some information from the XML to add useful links to other services. You may choose any service that you think would be useful, but the following examples could be interesting:
For this assignment, you are not supposed to actually contact the services you link to (we will do this is the next assignment), so all you need to do is figure out how to assemble the HTML code which is required to generate such a link. For example, for the three examples above, in the HTML that you generate, there should be something similar to the following markup for one example entry:
You can use your HTML form from the last assignment to build an HTML interface to your new PHP. Your old interface will now produce an output which not only shows information from the bibliography search service, but also provides convenient shortcuts to get more information from other services. |
|
please send comments to dret@sims.berkeley.edu last modification on Friday, 02-Mar-2007 19:39:32 MET |
|