In XML, tags may have attributes assigned as name/value pairs. For example, in the XML document describing a test for the Math Game, I could extend the definition of the <test> tag to include a test identification number for the purpose of describing the level of difficulty.
In this example, testID is an attribute of the tag <test> and it must be assigned a value using quotes.
Use child elements instead of attributes as much as possible in your XML documents. There are no rules in XML that state when to use attributes or child elements; however, it is usually easier to include a child element instead of an attribute. For example, instead of using the testID attribute, you could just as easily include it as a child element of <test>.
Was this article helpful?