Home arrow XML arrow Page 8 - XML Basics (part 1)

Anyone For Chicken? - XML

Struggling with XML? Can't figure out the difference between an entity and a namespace? Fear not - our XML series has all the answers. This introductory article discusses the origins and design goals of XML, the basic rules of XML markup, and how to use elements and attributes in an XML document.

TABLE OF CONTENTS:
  1. XML Basics (part 1)
  2. A Little History
  3. The Big Picture
  4. The Hammer And The Chisel
  5. Lights, Camera, Action!
  6. Breaking It Down
  7. Simply Element-ary
  8. Anyone For Chicken?
  9. To Attribute Or Not To Attribute...
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 4
July 23, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Let's look at another example:

<?xml version="1.0"?> <recipe> <name>Chicken Tikka</name> <author>Anonymous</author> <date>1 June 1999</date> <ingredients> <item> <desc>Boneless chicken breasts</desc> <quantity>2</quantity> </item> <item> <desc>Chopped onions</desc> <quantity>2</quantity> </item> <item> <desc>Ginger</desc> <quantity>1 tsp</quantity> </item> <item> <desc>Garlic</desc> <quantity>1 tsp</quantity> </item> <item> <desc>Red chili powder</desc> <quantity>1 tsp</quantity> </item> <item> <desc>Coriander seeds</desc> <quantity>1 tsp</quantity> </item> <item> <desc>Lime juice</desc> <quantity>2 tbsp</quantity> </item> <item> <desc>Butter</desc> <quantity>1 tbsp</quantity> </item> </ingredients> <servings> 3 </servings> <process> <step>Cut chicken into cubes, wash and apply lime juice and salt</step> <step>Add ginger, garlic, chili, coriander and lime juice in a separate bowl</step> <step>Mix well, and add chicken to marinate for 3-4 hours</step> <step>Place chicken pieces on skewers and barbeque</step> <step>Remove, apply butter, and barbeque again until meat is tender</step> <step>Garnish with lemon and chopped onions</step> </process> </recipe>
Since each markup tag has a name which describes the data contained within it, it becomes possible to break up an unorganized document into structured, atomic parts. In the example above, the <author> tag identifies the data contained within it to be the name of the recipe author, while the <desc> and <quantity> tags are used to identify ingredients and their respective quantities.

The textual content which appears between the opening and closing tags is referred to as "character data"...or, as the XML specification puts it, "all text that is not markup constitutes the character data of the document." Although this character data may contain alphanumeric characters or symbols, care should be taken to escape special characters like angle brackets and ampersands by replacing them with the corresponding hexadecimal representation or the strings

&lt; &gt; &amp;
respectively.

For example, while the following XML markup would generate an error,

to your left < is the yellow brick road
this would be absolutely fine.

to your left &lt; is the yellow brick road
Similarly, while

Barnes & Noble
would produce an error,

Barnes &amp; Noble
would have no trouble at all.

This article copyright Melonfire 2001. All rights reserved.

 
 
>>> More XML Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

XML ARTICLES

- Google Docs and Xpath Data Functions
- Flex Array Collection Sort and Filtering
- The Flex Tree Control
- Flex List Controls
- Working with Flex and Datagrids
- How to Set Up Podcasting and Vodcasting
- Creating an RSS Reader Application
- Building an RSS File
- An Introduction to XUL Part 6
- An Introduction to XUL Part 5
- An Introduction to XUL Part 4
- An Introduction to XUL Part 3
- An Introduction to XUL Part 2
- An Introduction to XUL Part 1
- XML Matters: Practical XML Data Design and M...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: