|
What is an Attribute? An attribute is the tag within XML that tells what ever is reading it (Google base in this case), what it does.
What is XML? Attributes and XML might sound like geeky techy talk but they are actually very very simple to understand.
The feed we generate in this plugin uses a very simple primitive programming language called XML, it takes the data from your products and converts it into XML
Ill show you what XML is, don't be worried, it is honestly so basic even a teenager with too many hormones could understand it! Even though you don't really need to know this, it will help hugely if you understood it, as then the error reports from Google are very easy to understand.
Basic XML Basically the whole thing involves 2 tags, an opening tag and a closing tag.
<title> - the opening tag </title> - the closing tag
Anything without a / is an opening tag, anything with an / is a closing tag.
Anything between those tags are what it is trying to tell you.
So <title>This is a demo</title> Is trying to tell "This is a demo".
It really is that easy!
It doesn't matter if there is lines between things like this <title> This is a demo </title>
or if is jumbled up on different lines like this
<title> This is a demo </title>
It all works the same as it is a very lazy language and just looks for the next character. It is usually easier to actually have it dropped down, so you can read it easier. You will see why in the next bit
Nesting The next part to learn is the "nesting", basically putting tags inside tags. Once you get this, that's it, there is nothing else to know.
So as Google calls products "Items", we will set up a little bit of XML to tell Google we are uploading an item.
<item></item>
And anything between them is the content of that item. But as there are a few parts to it, such as a title, description, price, and an image, each one goes in separately, so lets put out title in the item.
<item><title>This is a demo</title></item>
I have colour coded it, so you can see the opening and closing tags. But as this is all on one line, it looks a little confusing, so lets put them on different lines
<item> <title>This is a demo</title> </item>
So as you can see, the title tag just sits in between the item tags, it really is basic. If we want add in more attributes, we just add them in, so lets put in the title, link and description and colour code them all different so you can see each.
<item>
<title>This is a demo</title>
<description>This is the description of the product</description>
<link>http://www.joomlagooglebase.com</link>
<image>http://www.joomlagooglebase.com/image.jpg</image>
</item>
You can see that all the tags, called attributes, are nested in between the item tags. So when Google reads it, it knows that anything between the 2 item tags is all together, so this is all related to the same product. Some ways to make it even more readable is to indent the text, like i have done there. It means w can see at a glance, which parts are parent and which parts are child.
So basically an Attribute (for the Google Base project), is a child of the product tags. Something that tells you about a specific part of the product.
it really isn't hard to understand, it is very basic and so easy people get confused as they try to find more as they think it cant be that simple when it really is!
So what is an Attribute An Attribute is the sub tag, the title, price, description, weight, or whats ever is added. It tells Google all about your product, and gives it away to compare it against other products.
|