Link: Hail to the Victors: Back to basics with xml.... asks slightly fewer than a billion questions. I attempt to answer them below:
If this is the case, is your only incentive for choosing logical tag names to provide clarity for anyone reading the xml script? Or, do the name of tags actually matter?
First, you should think of XML as a message passing format (anticipating later points). Now two things regarding this little cluster of questions:
- Nothing in xml per se says what you have to name the tags or elements. The only thing is that you follow the rules of well-formedness (one root element, all elements nested, element and attribute names only have the allowed characters, various other smaller rules).
- Now, that all sounds very free form. How do I know what the elements mean? What should be inside of them? What are the legal tags for a particular document? That's where we use something like a DTD, W3 Schema, or Relax NG (all referred to hence as schema) to define what may and may not appear in the document. Essentially, schema tell what the tags have to be, the type of data that may be in the them, and essentially the same for attributes. In your example, the schema would tell us what could appear in a telegram document.
On to your next issue,
I know that you can have a blank tag, but does the name actually appear someplace within the document text? For example, would the first line of the above document display “to Sarah Bellum” or just “Sarah Bellum”?
Here, by a blank tag, I think you mean empty tag, like <telegram/>. The telegram tag has nothing inside of it. It is empty. Now, as for your question as to how tags would display, there wind up being a few default rules. Most browsers now display xml as a set of nested tags, unless you provide the browser with a set of instructions for how to display the tags. HTML, an XML vocabulary, has in the past defined how elements should be displayed by browsers.
Now, you ask:
I am also confused about attributes. From the article, I gather that you can have multiple elements with the same name, but every attribute of an element must have a unique name. Can attributes of different elements have the same name? For example, if you had the elements “cake” and “ice-cream,” could you use the same attribute name “chocolate” for each?
You are correct that attributes within elements must have unique names. Attributes must only be unique by element. People use boolean attributes like "chocolate", but you might want a multi-valued attribute like "flavor" instead.
The article says that you use attributes to specify categories of elements so that you do not have to create a new element for every situation. Is it a bad thing if you create a document with 500 different elements?
It is not bad to have 500 different elements, just potentially unwieldly. Attributes and elements are almost the same thing. In some situations, it comes down to personal preference. For you, the main thing is to know that there is something called attributes and how they work. you don't necessarily have to use them.
Also, I am confused about the concept of the root element. Is it correct to think of it in the same sense as the title of a document? Just like a document can only have one title, the elements of an xml script can only have one root element?
I think of the root element as telling you the type of document you are dealing with. In the example you give, we are dealing with a telegram document.