|Page (1) of 1 - 05/03/10||email article||print page|
Real-World XML: Part 7 of 12Using required and optional elements in Atom
XML technologies offer web developers and designers more flexibility than ever before. In Real-World XML, industry expert Joe Marini covers the best programming practices with XML, including the tools needed to build effective XML structures. He demonstrates the implementation of XML formats, how these formats work in real-world situations, and how they can facilitate project planning and development. Exercise files accompany the course.
XML Essential Training is a prerequisite for getting the most out of this course.
?Understanding the Sitemap index format
?Integrating XML and design
?Using XML effectively in Firefox and Internet Explorer
?Avoiding common design mistakes
?Understanding and implementing DOM algorithms
?Building an XML tag set
?Using XML with RSS and Atom
?Processing XML data with XSLT
Using required and optional elements in Atom
Atom feed tags have some required elements in order to make the feed useful and I have listed the three elements that are required on the feed tag here.
The first one is the title tag. The title tag indicates the name of what the feed is and this is usually, but it's not required to be, the name of the website that supplies the feed.
Now if it's not the name of the website, you can make it whatever you want, but in any case, you should not leave this field blank because it's what most feed readers use to display the name of the feed to the user and I have provided some examples of each one of these tags, you can see there are on the right.
The next tag is the id tag and the id tag is a unique identifier for your feed. Now, you are not limited to using URLs, you can use any value here that is going to be guaranteed to be unique and there are numerous schemes out there on the web that create unique ids for you, one you might want to consider looking up in addition to URLs is the UUID Generator on the web. There's several of those.
Usually though, you will just use your website, address domain in your feed's id. The next required tag is the updated tag and this indicate for last time that the feed was modified in a "significant" way. Now the spec does not say what the word significant means, it leaves that up to the publisher. Usually what this means is the last time that the content of the feed was modified.
Not necessarily the fixed typos or anything like that, but when the content itself was changed and this specifies a date. Date values have to conform to one of the formats I have listed there in the description field for updated.
Click Play or press spacebar to start or stop video
And you can look up any of these on the web. But I have provided an example over there on the right-hand side which specifies a date using the four character year, a two character month and a two character day and the then the character T which separates the time relative to GMT zone.
Okay, so if you go back now and take a look at our feed tag. It's been updated to reflect the required tags, <title>, <update> and <id>. You can see what it looks like now. So now we have our title, which is my Atom feed. We have the updated tag put in there, and we have an id which points to my website. Okay, let's continue on looking some of the recommended and optional elements of the feed tag.
The top table here lists two recommended tags offer and link and the lower table lists elements that are considered to be optional of the feed tag. So the author tag, and you can have more than one of these. It indicates the author of the feed and as I said, you can have multiple authors. The author tag is required unless all of the <entry> elements in the feed have authors as well.
And you specify an author tag using the Atom "Person" construct. The "Person" construct you can look this up in the spec but it essentially contains three tags: name, email and URL.
I have specified the name and the email over there in the example. Name is the only one that's required. Email and URL are optional. The link tag identifies a web page that's related to this feed and every feed should provide a link to itself and you can see over on the right-hand side there I have provided an example link and we'll see this in action later.
Moving on to the optional elements, the category elements specifies a category that the feed belongs to, you can have more than one of these. The category basically contains a term attribute and inside the term attribute you specify the category that you want your feed to belong to and if you have multiple categories, you can just use multiple categories and specify a term for each.
The contributor tag is similar to the author. This identifies a person who contributes to the feed and like authors there can be multiple contributors and these are specified using the same format as the author tag with name and email and URL and again email and URL are optional.
The generator tag indicates the software that generated the feed and you can put any value in here you want. And then there's the icon tag, which specifies an optional icon for the feed. And in the icon tag, you essentially provide a path on your site to the icon.
Okay, so now let's go back and take a look at the feed source. We have updated it now to reflect the feed tag elements, <author>, <category>, <link> and <icon> and you can see I have put them in bold there. Okay. So that's a brief introduction to the Atom Format. What we are going to do now in the next section is move on to adding entries to our Atom feed and we'll see a complete example at the end of the section.
www.lynda.com is an award-winning provider of educational materials, including Hands-On Training instructional books, the Online Training Library, CD- and DVD-based video training, and events for creative designers, instructors, students, and hobbyists.
The lynda.com Online Training Library and CD-ROM titles include such subjects as Photoshop, Flash, Dreamweaver, Illustrator, Office, digital photography, Web design, digital video, and many others. lynda.com's all-star team of trainers and teachers provides comprehensive and unbiased movie-based training to an international membership of tens of thousands of subscribers. Considering the speed at which technology evolves, the Online Training Library is a great solution for keeping your skills current. Library subscriptions begin as low as $25 a month, with no long-term commitment required.
Joe Marini is the director for Microsoft's Visual Studio Industry Partner program, and has been active in the Web and graphics industries for more than 15 years. He was an original member of the Dreamweaver engineering team at Macromedia, and has also held prominent roles in creating products such as QuarkXPress, mFactory's mTropolis, and Extensis QX-Tools. He is regularly a featured speaker at industry conferences and has authored or co-authored several books on Web development. His book The Document Object Model is widely regarded as the definitive resource for working with the DOM.
Related Keywords:xml, Extensible Mark-Up Language, xml training, xml tutorial, xml techniques, xml design, web design, web site design, atom feeds