and rules by which the XML elements are defined in the WSDL, however, are the same. Because a web
server handles multiple requests that implement multiple WSDLs, each request must specify the WSDL
it is using..
XML Syntax
XML tools enforce XML syntax. XML syntax is very similar to HTML syntax, except, like XHTML, the
syntax is strictly enforced. The syntax is:
• Tags are enclosed within angle brackets, for example, <para>
• Opening tags must be paired with closing tags, for example, <para>Sentence</para>
• Opening and closing tags must be nested correctly, for example, the following example is well formed
<note><para>Sentence</para></note>
The following example is not well formed
<note><para>Sentence</note></para>
If these syntax rules are followed, the XML document is said to be well formed. That does not mean,
however, that the tags in the XML document are necessarily the ones defined in the associated WSDL.
If, for example, the WSDL defines <para>, an XML document that uses <Para> would cause an error
because "Para" is not defined in the WSDL. When an XML document is well formed and the tags it uses
conform to tags defined in the WSDL, the document is said to be valid. Product Advertising API responses
always contain valid XML.
XML Structures
Some data in XML documents are one dimensional, for example, <para>Sentence</para>. Some data,
however, is structured, as shown in the following XML snippet.
<SubTotal>
<Amount>2998</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$29.98</FormattedPrice>
</SubTotal>
This example shows that the subtotal is comprised of three pieces of data:
Amount
,
CurrencyCode
, and
FormattedPrice
. The example also shows that there can be a hierarchy of tags. In this example, Amount
is a child tag of Subtotal. These structures represent arrays of values.
Using XML
So, what do you do with the XML response? The good news is that the Product Advertising API returns
a well-defined set of tags for each kind of request. That means that you can use parsing mechanisms to
pull out of the XML responses the data that you would like to submit in a second request, or, display on
a web page. For instance, in the preceding example, you might parse the XML document to find
FormattedPrice so that you could display the $29.98 on a web page that shows an item for sale.
XML is not only used to create requests and responses, it is also used to create a WSDL, which defines
the XML tags.
API Version 2011-08-01
13
Product Advertising API Developer Guide
What is XML?