XML Elements
An XML document contains XML Elements.
What is an XML Element?
An XML element is everything from (including) the element's start tag
to (including) the element's end tag.
An element can contain other elements, simple text or a mixture of both. Elements can also have attributes.
<bookstore>
<book category="CHILDREN">
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
|
In the example above, <bookstore> and <book> have element contents, because
they contain other elements. <author> has text content because it contains text.
In the example above only <book> has an attribute
(category="CHILDREN").
XML Naming Rules
XML elements must follow these naming rules:
- Names can contain letters, numbers, and other characters
- Names must not start with a number or punctuation character
- Names must not start with the letters xml (or XML, or Xml, etc)
- Names cannot contain spaces
Any name can be used, no words are reserved.
Best Naming Practices
Make names descriptive. Names with an underscore separator are nice: <first_name>,
<last_name>.
Names should
be short and simple, like this: <book_title> not like this: <the_title_of_the_book>.
Avoid "-" characters. If you name something "first-name,"
some software may think you want to subtract name from first.
Avoid "." characters. If you
name something "first.name," some software may think that "name" is a property
of the object "first."
Avoid ":" characters. Colons are reserved
to be used for something called namespaces (more later).
XML documents often have a corresponding database. A
good practice is to use the naming rules of your database for the elements in the XML documents.
Non-English letters like йтб are perfectly legal in XML, but
watch out for problems if your software vendor doesn't support them.
XML Elements are Extensible
XML elements can be extended to carry more information.
Look at the following XML example:
<note>
<to>Tove</to>
<from>Jani</from>
<body>Don't forget me this weekend!</body>
</note>
|
Let's imagine that we created an application that extracted the <to>,
<from>, and <body> elements from the XML document to produce this
output:
|
MESSAGE
To: Tove
From: Jani
Don't forget me this weekend!
|
Imagine that the author of the XML document added some extra information to
it:
<note>
<date>2008-01-10</date>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
|
Should the application break or crash?
No. The application should still be able to find the <to>,
<from>, and <body> elements in the XML document and produce the same
output.
One of the beauties of XML, is that it can often be extended without breaking
applications.
The Ektron Intranet
lets you do everything you need to do on your corporate intranet and everything you want to do... all with just one application.
What can you do with the Ektron Intranet? |

|
Navigate through content, documents, assets, colleagues and workgroups quickly and intuitively with enterprise search |

|
Communicate with friends and colleagues with forums, message boards and corporate blogging using the new Social Networking Platform |

|
Promote collaboration among coworkers in your organization through project workspaces where others can efficiently find information and work together |

|
Personalize your company profile by bookmarking and organizing favorite content, uploading assets, posting photos, blogging, and more |

|
Interact with features like tagging, flagging, wikis and ratings found in the Web 2.0 Toolbox |
 |
Author/edit content, manage navigation, menus, audit trails, workflow and approvals with the best in breed Content Management |
|
|
|
|
See why there are 20,000+ Ektron integrations worldwide. Request an
INSTANT DEMO or download a
FREE TRIAL today. |
|