- 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
Long before Yahoo! unveiled Yahoo! Web Services, developers were accessing the information in Google's database of 8 billion web pages through a web services interface.
Part of
Google's offering is fairly standard. Using the API, you can perform the same searches
you can perform through
the web interface, except that instead of a web page, you get back an XML
document of results, which you can then analyze or display however you
like. The web services API actually
uses the exact same queries as the web site, including modifiers such as site:
and intext:
. (We'll look more closely
at the actual searches in a future guide section.)
Searches are done using SOAP messages. For example, if I were searching for conspiracy theories, I might send a SOAP message such as:
<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <key xsi:type="xsd:string">00000000000000000000000000000000</key> <q xsi:type="xsd:string">government conspiracies</q> <start xsi:type="xsd:int">0</start> <maxResults xsi:type="xsd:int">10</maxResults> <filter xsi:type="xsd:boolean">true</filter> <restrict xsi:type="xsd:string"></restrict> <safeSearch xsi:type="xsd:boolean">false</safeSearch> <lr xsi:type="xsd:string"></lr> <ie xsi:type="xsd:string">latin1</ie> <oe xsi:type="xsd:string">latin1</oe> </ns1:doGoogleSearch> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
The response would also be a SOAP message, such as:
<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:doGoogleSearchResponse xmlns:ns1="urn:GoogleSearch" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="ns1:GoogleSearchResult"> <documentFiltering xsi:type="xsd:boolean">false</documentFiltering> <estimatedTotalResultsCount xsi:type="xsd:int">718000</estimatedTotalResultsCount> <directoryCategories xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Array" ns2:arrayType="ns1:DirectoryCategory[0]"></directoryCategories> <searchTime xsi:type="xsd:double">0.194871</searchTime> <resultElements xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Array" ns3:arrayType="ns1:ResultElement[3]"> <item xsi:type="ns1:ResultElement"> <cachedSize xsi:type="xsd:string">40k</cachedSize> <hostName xsi:type="xsd:string"></hostName> <snippet xsi:type="xsd:string"> <b>Conspiracy</b> related news and discusion. Main topics include <b>government</b> cover-ups, freemasons, illuminati, aliens, ufo's, secret societies, politics, ...</b></snippet> <directoryCategory xsi:type="ns1:DirectoryCategory"> <specialEncoding xsi:type="xsd:string"></specialEncoding> <fullViewableName xsi:type="xsd:string"></fullViewableName> </directoryCategory> <relatedInformationPresent xsi:type="xsd:boolean">true</relatedInformationPresent> <directoryTitle xsi:type="xsd:string"></directoryTitle> <summary xsi:type="xsd:string"></summary> <URL xsi:type="xsd:string">http://www.abovetopsecret.com/</URL> <title xsi:type="xsd:string"><b>AboveTopSecret.com - The Internet's Most Popular Conspiracy ...</b></title> </item> <item xsi:type="ns1:ResultElement"> <cachedSize xsi:type="xsd:string">100k</cachedSize> <hostName xsi:type="xsd:string"></hostName> <snippet xsi:type="xsd:string">Alternative news and commentary on corporate/<b>government</b> fraud and criminal <b>conspiracy</b>. Features "Behind the Scenes in the Beltway," a column by <b>government</b> ...</snippet> <directoryCategory xsi:type="ns1:DirectoryCategory"> <specialEncoding xsi:type="xsd:string"></specialEncoding> <fullViewableName xsi:type="xsd:string"></fullViewableName> </directoryCategory> <relatedInformationPresent xsi:type="xsd:boolean">true</relatedInformationPresent> <directoryTitle xsi:type="xsd:string"></directoryTitle> <summary xsi:type="xsd:string"></summary> <URL xsi:type="xsd:string">http://www.almartinraw.com/</URL> <title xsi:type="xsd:string">Al Martin Raw: Criminal Government Conspiracy</title> </item> ... <endIndex xsi:type="xsd:int">10</endIndex> <searchTips xsi:type="xsd:string"></searchTips> <searchComments xsi:type="xsd:string"></searchComments> <startIndex xsi:type="xsd:int">1</startIndex> <estimateIsExact xsi:type="xsd:boolean">false</estimateIsExact> <searchQuery xsi:type="xsd:string">government conspiracies</searchQuery> </return> </ns1:doGoogleSearchResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Depending on what I wanted to do with the data, I could either extract specific
pieces of information (such as the estimated number of results) or I could extract
the payload of the SOAP message, the contents of the doGoogleSearchResponse
element, and use XSLT to display it on a web page.
The actual formats of these messages are detailed in a WSDL file, so if your programming environment supports complex types -- notice that the results come back as nested XML documents rather than simple types -- you can use the WSDL file to generate a client.
Not that you would necessarily need to. The Google API Software Developer's Kit includes sample code for both Java and .NET, including a Java library that makes requesting and working with results fairly straightforward.
Google actually provides a web services interface to three of its offerings. The first, and most obvious, is search, where you can submit a query and receive a list of pages that satisfy that query. The second is Google's cache database, where you can submit a URL and get back the contents of the page the last time Google indexed it. The third is Google's spell-check, which takes a word (or an attempt at spelling a word) and gives back a list of suggested spellings.
Any one (or more) of these searches can be integrated into your own applications. For example, you could write an application that does a spell-check on user-supplied text, or one that enables you to determine whether your web page is in the top ten results for a particular keyword.
Not that there aren't restrictions of course. The Google Web Service API has been "experimental" and "in beta" since its release several years ago, which means that Google can justify limiting the functionality of the service. For example, you, as a developer, can only request 1000 results per day with your application, no matter how many people are visiting it. (Although I should point out that some developers get around this problem by requiring users to supply their own license key, which Google provides free for tracking purposes.) You are also limited to 10 results at a time, and only the first 1000 results are available for any given search. Commercial applications are permissible with written approval from Google, but are still limited to 1000 requests per day.
Next, a look at actually using the API.