- XML Reference Guide
- Overview
- What Is XML?
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Table of Contents
- The Document Object Model
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- DOM and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Implementations
- DOM and JavaScript
- Using a Repeater
- Repeaters and XML
- Repeater Resources
- DOM and .NET
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Downloads
- DOM and C++
- DOM and C++ Resources
- DOM and Perl
- DOM and Perl Resources
- DOM and PHP
- DOM and PHP Resources
- DOM Level 3
- DOM Level 3 Core
- DOM Level 3 Load and Save
- DOM Level 3 XPath
- DOM Level 3 Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- The Simple API for XML (SAX)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SAX and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- SAX and .NET
- Informit Articles and Sample Chapters
- SAX and Perl
- SAX and Perl Resources
- SAX and PHP
- SAX and PHP Resources
- Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Document Type Definitions (DTDs)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Schemas
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- RELAX NG
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Schematron
- Official Documentation and Implementations
- Validation in Applications
- Informit Articles and Sample Chapters
- Books and e-Books
- XSL Transformations (XSLT)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XSLT in Java
- Java in XSLT Resources
- XSLT and RSS in .NET
- XSLT and RSS in .NET Resources
- XSL-FO
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XPath
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Base
- Informit Articles and Sample Chapters
- Official Documentation
- XHTML
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XHTML 2.0
- Documentation
- Cascading Style Sheets
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XUL
- XUL References
- XML Events
- XML Events Resources
- XML Data Binding
- Informit Articles and Sample Chapters
- Books and e-Books
- Specifications
- Implementations
- XML and Databases
- Informit Articles and Sample Chapters
- Books and e-Books
- Online Resources
- Official Documentation
- SQL Server and FOR XML
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- Service Oriented Architecture
- Web Services
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Creating a Perl Web Service Client
- SOAP::Lite
- Amazon Web Services
- Creating the Movable Type Plug-in
- Perl, Amazon, and Movable Type Resources
- Apache Axis2
- REST
- REST Resources
- SOAP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SOAP and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- WSDL
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- UDDI
- UDDI Resources
- XML-RPC
- XML-RPC in PHP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Ajax
- Asynchronous Javascript
- Client-side XSLT
- SAJAX and PHP
- Ajax Resources
- JSON
- Ruby on Rails
- Creating Objects
- Ruby Basics: Arrays and Other Sundry Bits
- Ruby Basics: Iterators and Persistence
- Starting on the Rails
- Rails and Databases
- Rails: Ajax and Partials
- Rails Resources
- Web Services Security
- Web Services Security Resources
- SAML
- Informit Articles and Sample Chapters
- Books and e-Books
- Specification and Implementation
- XML Digital Signatures
- XML Digital Signatures Resources
- XML Key Management Services
- Resources for XML Key Management Services
- Internationalization
- Resources
- Grid Computing
- Grid Resources
- Web Services Resource Framework
- Web Services Resource Framework Resources
- WS-Addressing
- WS-Addressing Resources
- WS-Notifications
- New Languages: XML in Use
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Google Web Toolkit
- GWT Basic Interactivity
- Google Sitemaps
- Google Sitemaps Resources
- Accessibility
- Web Accessibility
- XML Accessibility
- Accessibility Resources
- The Semantic Web
- Defining a New Ontology
- OWL: Web Ontology Language
- Semantic Web Resources
- Google Base
- Microformats
- StructuredBlogging
- Live Clipboard
- WML
- XHTML-MP
- WML Resources
- Google Web Services
- Google Web Services API
- Google Web Services Resources
- The Yahoo! Web Services Interface
- Yahoo! Web Services and PHP
- Yahoo! Web Services Resources
- eBay REST API
- WordML
- WordML Part 2: Lists
- WordML Part 3: Tables
- WordML Resources
- DocBook
- Articles
- Books and e-Books
- Official Documentation and Implementations
- XML Query
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XForms
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Resource Description Framework (RDF)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Topic Maps
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation, Implementations, and Other Resources
- Rich Site Summary (RSS)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Simple Sharing Extensions (SSE)
- Atom
- Podcasting
- Podcasting Resources
- Scalable Vector Graphics (SVG)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- OPML
- OPML Resources
- Summary
- Projects
- JavaScript TimeTracker: JSON and PHP
- The Javascript Timetracker
- Refactoring to Javascript Objects
- Creating the Yahoo! Widget
- Web Mashup
- Google Maps
- Indeed Mashup
- Mashup Part 3: Putting It All Together
- Additional Resources
- Frequently Asked Questions About XML
- What's XML, and why should I use it?
- What's a well-formed document?
- What's the difference between XML and HTML?
- What's the difference between HTML and XHTML?
- Can I use XML in a browser?
- Should I use elements or attributes for my document?
- What's a namespace?
- Where can I get an XML parser?
- What's the difference between a well-formed document and a valid document?
- What's a validating parser?
- Should I use DOM or SAX for my application?
- How can I stop a SAX parser before it has parsed the entire document?
- 2005 Predictions
- 2006 Predictions
- Nick's Book Picks
For a few years now, Google's been the only game in town for developers looking to easily access a major search engine's data in their applications.
Not anymore.
Yahoo!, possibly as part of a bid to win the hearts and minds of developers and other early adopter types, has released Yahoo! Web Services v1.0, which enables developers to make use of Yahoo! search results in their own applications.
Yahoo! Web Services has one major difference from Google Web Services: it uses REST, rather than SOAP.
That means that getting the result of a search is a sample matter of constructing an appropriate URL and calling it. Rather than building a special client application, as you must do for a SOAP request, you can simply call a REST URL from the browser, if all you're intersted in is seeing the results.
For example, I can do a web search term "firefly" by calling the following URL:
http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=InformITXML&query=firefly&format=html
Don't worry about the actual URL -- we'll get to that in a moment.
When I enter that URL in my browser, I get a response something like this. (Click to see the full-size image.)
Of course, it's not much use that way; if I wanted to see the results myself, I'd be much better off simply using the Yahoo! web site. No, this data is meant to be used by an application. For example, I might want to display the top 5 results for "firefly" on one of my web pages. I could do that by constructing a routine that makes an HTTP connection and analyzes the resulting document. (In fact, I'll do that in the next section.)
Before we talk about how to build a search, let's talk about what you can search. Yahoo! has made available the following search services:
- Web Search: The classic web search, this service enables you to look for web pages that satisfy the requested query.
- Image Search: Searches for images on the world wide web. Results include the URL for the actual image, a thumbnail version of the image (if there is one) and the page on which the image appears.
- Video Search: Similar to the Image Search, this search enables you to search for video files on a particular topic. Results include the URL for the actual file as well as summary text (if available) and information on the file itself, such as how many audio channels it has and whether it's streaming or not.
- Local Search: Enables users to search for businesses that satisfy a particular query -- and that are within the specified radius of a target location. Results include business information and a map URL.
- News Search: Searches for news items that satisfy the specified query. Results include the URL for the actual item, as well as information on the source and date of the item.
Yahoo! also offers two sub-services: Spelling, which gives you the correct spelling for a term -- or at least a suggestion for the correct spelling -- and Related, which returns a list of queries that are thought to be related to the requested query.
Constructing a request for Yahoo! Web Services is the same as constructing any other REST request. For example, let's look at that "firefly" request we were talking about earlier. First, we need the base Web Search URL:
http://api.search.yahoo.com/WebSearchService/V1/webSearch
Next we need to add the parameters. Each parameter comes as a name-value pair. In our case, those name-value pairs are:
appid=InformITXML query=firefly format=html
The appid
is a an ID unique to your application; you register it with Yahoo! and it identifies requests made through your appliocation. The query is the search term you're looking for. The format is the type of results you're looking for. For example, you could search for just PDF files. (The default is to return all results.)
To put these parameters together, add a question-mark to the end of the base URL and join the name-value pairs with asterisks, as in:
http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=InformITXML&query=firefly&format=html
The result is a ResultSet
of Result
elements. The contents of the Result
elements depends on the type of search.
Next: using the Yahoo! Web Services 1.0 API.