Sub topic 10
Feed formats and submission methods
This chapter assumes you can read simple XML and tab-separated files, know the core product attributes from earlier chapters (id, title, price, availability, link, image_link), and can run a short Python script. It covers the formats a product feed can take, the ways to deliver it to a merchant account, and the mistakes that break delivery.
What a feed format decides
A feed format is the file layout that carries your product attributes. The format does not change which attributes shopping systems read. It changes how easily you can produce the file, how safely special characters are handled, and how well the file scales.
Three decisions come up in practice:
- Which file format to generate.
- How the file reaches the merchant account (the submission method).
- How often the file is refreshed (covered in detail in the freshness chapter).
The common formats
Google Merchant Center-style specifications accept two main text formats for feeds: tab-separated text and XML. XML feeds come in two flavors, RSS 2.0 and Atom 1.0. Both use the g: namespace for product attributes.
| Format | Typical extension | Strengths | Weaknesses |
|---|---|---|---|
| Tab-separated text (TSV) | `.txt`, `.tsv` | Easy to open in a spreadsheet, small files, simple to diff | No nesting, so repeated fields and multi-part attributes are awkward. Tabs or line breaks inside text corrupt rows. |
| XML (RSS 2.0) | `.xml` | Handles repeated fields and nested attributes such as shipping. Escaping rules are well defined. | Verbose, harder to inspect by eye, easy to produce invalid XML by hand |
| XML (Atom 1.0) | `.xml` | Same as RSS, with a stricter structure | Less common, so fewer tools and examples |
| Spreadsheet (Google Sheets) | sheet | Manual editing with no code | Does not scale, easy to introduce typing errors |
| API submission | none (JSON over HTTPS) | Fast single-item updates, good for price and stock changes | Requires development work and authentication |
If you generate the feed from a database or e-commerce platform, choose XML. If a person maintains a small catalog by hand, a spreadsheet or TSV file is enough. The decision usually turns on who produces the file and how many fields are nested.
Reading an XML item
The earlier chapters introduced a minimal RSS item. Here it is again, so you can see where the format-specific parts sit.
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>Example Store</title>
<link>https://www.example.com</link>
<description>Product feed for Example Store</description>
<item>
<g:id>SKU-1001-BLU-M</g:id>
<g:title>Acme Trail Runner Jacket - Men's, Blue, Medium</g:title>
<g:description>Lightweight water-resistant running jacket with a packable hood and reflective trim.</g:description>
<g:link>https://www.example.com/p/trail-runner-jacket?color=blue&size=m</g:link>
<g:image_link>https://www.example.com/img/trail-runner-jacket-blue.jpg</g:image_link>
<g:price>89.00 USD</g:price>
<g:availability>in_stock</g:availability>
<g:condition>new</g:condition>
<g:brand>Acme</g:brand>
<g:gtin>00012345678905</g:gtin>
<g:item_group_id>SKU-1001</g:item_group_id>
<g:color>Blue</g:color>
<g:size>M</g:size>
</item>
</channel>
</rss>Four format details matter here:
- The
xmlns:gdeclaration on<rss>defines the namespace. Without it, everyg:tag is invalid. - The ampersand in the URL is written
&. A bare&makes the whole file unparseable. - The feed has one
<channel>and one<item>per product variant. Each variant is its own item, linked byitem_group_id. - The price carries its currency code in the same value, such as
89.00 USD.
The same item as a TSV row
In TSV, the first row holds attribute names and each later row is one product. Attribute names are written without the g: prefix.
id title description link image_link price availability condition brand gtin item_group_id color size
SKU-1001-BLU-M Acme Trail Runner Jacket - Men's, Blue, Medium Lightweight water-resistant running jacket with a packable hood and reflective trim. https://www.example.com/p/trail-runner-jacket?color=blue&size=m https://www.example.com/img/trail-runner-jacket-blue.jpg 89.00 USD in_stock new Acme 00012345678905 SKU-1001 Blue MTSV needs no escaping for &. The danger is different: a tab or newline inside a description splits the row. Strip or replace both characters when you export. Also keep the file in UTF-8 so accented characters in titles survive.
Submission methods
A submission method is how the file gets from your system to the merchant account. Methods differ in who starts the transfer and how quickly changes arrive.
| Method | Who starts the transfer | Best for | Main risk |
|---|---|---|---|
| Scheduled fetch | The merchant account pulls a URL on a schedule | Catalogs generated on a server that can host a file | The URL is unreachable or needs a login the fetcher does not have |
| Upload | You push a file manually or by script | Small or occasional updates, first tests | The file goes stale because someone forgot to upload |
| SFTP or FTP | You push a file to a host; the account reads it | Large files, or platforms that cannot expose a public URL | Credentials, file naming, and permissions |
| Content API | Your code sends item-level requests | Frequent price and stock changes | Rate limits, authentication, and more code to maintain |
| Platform connector | An e-commerce plugin sends data | Hosted stores with built-in support | Limited control over how fields are mapped |
Scheduled fetch is the usual default. You publish the feed at a stable HTTPS URL, and the account downloads it at the times you choose. Because the account pulls the file, your server must allow the fetcher through. Common blockers are a login page, a firewall rule, a robots rule on the feed path, and a redirect chain that ends on an HTML page.
The API suits changes that cannot wait for the next scheduled fetch. A typical pattern combines both: a full feed once a day, plus API updates for price and availability between fetches. This pairing matters most when the feed and landing page must stay consistent, which a later chapter covers.
Choosing a format and method
Match the choice to constraints instead of defaulting to one option.
- Small catalog, hand-maintained: a spreadsheet or TSV upload is enough. Accept that it will need manual refreshes.
- Mid-size catalog from a platform: use the platform connector if mapping is adequate. Otherwise generate XML and use scheduled fetch.
- Large catalog, server-generated: XML or TSV over scheduled fetch or SFTP. Compress the file with gzip if the specification allows it, and split the feed only if a single file exceeds size limits.
- Fast-changing prices or stock: keep the full feed on a schedule and add the API for deltas.
Check the current size limits and supported compression in the specification you submit to. Those limits change, so do not hard-code them into your tooling without reading the documentation.
Common errors
Most delivery failures come from a few causes.
- Wrong content type or an HTML response. The fetch URL returns a login page or an error page with a 200 status. The account sees HTML where it expected a feed.
- Invalid XML. Unescaped
&,<, or stray control characters. Parse the file with an XML library before publishing it. - Encoding mismatch. The file claims UTF-8 but contains another encoding. Names with accents turn into garbage.
- Duplicate ids. Two rows share an
id. Later rows can overwrite earlier ones, so a variant disappears without a visible error. - Price without currency, or with a thousands separator.
1,299.00is a common cause of parse failures. Use1299.00 USD. - Stale hosted file. A cached copy at a CDN or proxy keeps serving yesterday's feed. Check cache headers on the feed URL.
- Mixing feed sources. Two feeds supply the same item id with different prices. Decide which source owns each product.
A short check you can run today
Before you publish a feed, parse it and count items and duplicate ids. The script below uses only the Python standard library and works on RSS files.
import sys
import xml.etree.ElementTree as ET
from collections import Counter
NS = {"g": "http://base.google.com/ns/1.0"}
def main(path):
root = ET.parse(path).getroot()
ids = []
for item in root.iter("item"):
node = item.find("g:id", NS)
ids.append(node.text.strip() if node is not None and node.text else "")
counts = Counter(ids)
duplicates = [i for i, n in counts.items() if n > 1 or i == ""]
print("items: " + str(len(ids)))
print("duplicate or empty ids: " + str(len(duplicates)))
for i in duplicates:
print(" " + (i or "(empty)") + " x" + str(counts[i]))
return 1 if duplicates else 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1]))ET.parse raises an error if the XML is malformed, so this script catches invalid files and duplicate ids in one run. The fuller validation script appears in the validation chapter.
Summary of decisions
| Question | Guidance |
|---|---|
| Who produces the file? | A person: spreadsheet or TSV. Code or a platform: XML. |
| Does the data nest? | Yes: XML. No: TSV is fine. |
| Can a server host a public HTTPS URL? | Yes: scheduled fetch. No: SFTP or upload. |
| Do prices or stock change within the day? | Add the API alongside the full feed. |
Exercise
Your RSS feed fails to parse. The only change since yesterday is a new product whose link is https://www.example.com/p/shoe?color=red&size=9. What is the cause, and how do you fix it?
Show answer
The bare ampersand between color=red and size=9 is not valid XML. Write it as & so the link reads https://www.example.com/p/shoe?color=red&size=9. A TSV feed would not have this problem, since TSV needs no escaping for ampersands.
Exercise
A store changes prices several times a day, but the account fetches its feed once every 24 hours. Which submission setup closes the gap, and why keep the full feed?
Show answer
Keep the daily scheduled fetch of the full feed and add Content API updates for price and availability changes. The full feed keeps the whole catalog consistent and recovers from missed updates. The API delivers urgent changes without waiting for the next fetch.
Exercise
A feed URL returns status 200 but the account reports it cannot read any items. Name two likely causes and one way to check each.
Show answer
The URL may return an HTML login or error page instead of the feed. Check by requesting the URL without cookies and reading the first lines of the response. The file may also be invalid XML or the wrong encoding. Check by parsing it with an XML library and confirming it is UTF-8.