📄️ CDATA in XML Files
Since XML is a tag based language: content some characters like brackets (``) are reserved for the XML markup itself. If your data contains these characters it may cause a parser to become confused. We recommend that you embed all fields that contain string values in CDATA tags in order to avoid the risk of your content causing troubles for our parser.
📄️ Special Characters in XML
It is possible to escape special characters in XML (see this answer and this answer) using number notations such as this example:
XML
Overview
XML stands for eXtensinble Markup Language. It is very similar to HTML except it doesn't have any predefined tags. It's a meta language that allows you to define your own markup language which then can be used to store and share data in a structured manner.
Namespaces
A Prisjakt offer feed should use two namespaces, the g
namespace which most fields belong to that are defined by the Google Product Specification and then the pj
namespace which contains some additional Prisjakt specific fields defined by us.
Offers: https://schema.prisjakt.nu/ns/1.0
<rss xmlns:pj="https://schema.prisjakt.nu/ns/1.0" xmlns:g="http://base.google.com/ns/1.0" version="3.0">
Promotions: https://schema.prisjakt.nu/ns/promotions-1.0
<rss xmlns:pj="https://schema.prisjakt.nu/ns/promotions-1.0" xmlns:g="http://base.google.com/ns/1.0" version="3.0">
Namespace Priority When Parsed
If multiple fields with the same name but different namespaces exist, the field will be parsed with the following priority:
pj:
first eg.<pj:some_field>Some pj field</pj:some_field>
g:
second eg.<g:some_field>Gome g field</g:some_field>
- no namespace third eg.
<some_field>Some field</some_field>
- other/unknown in undefined order eg.
<xyz:some_field>Some xyz field</xyz:some_field>
Recommendations
Use UTF-8
All XML feeds should start with the following header and the files should be properly UTF-8 encoded.
Do not use control characters in feed file. We support some of them trying to follow XML spec but not guarantee to fully support it.
<?xml version='1.0' encoding='UTF-8'?>
Use CDATA
You should lower the risk of your data causing xml parsers to fail because of invalid data by encoding your data correctly. Take a look on our CDATA article to achieve this.