Bambookit Home    Bambookit GUI Tutorial


Chapter 5. XML file

Now let's begin writing our XML document. The very first line of every XML document must be the XML declaration:

<?xml version="1.0"?>

The following explains each part of the XML declaration:

<? is required. Begins a processing instruction.
xml is required. Declares this to be an XML instruction.
version="" is required. Identifies the version of XML specification in use. Version 1.0 is the only current version so the value must be 1.0
standalone="" is optional. States if this file is complete by itself. A no value signals the parser that it should import other mark-up files, such as an external DTD. Because well-formed XML docs are complete by itself, this attribute value would be yes.
encoding="" is optional. Indicates which international character set is used. ISO-8859-1 is the default and is essentially the English character set.
?> is required. Terminates the processing instruction.

XML documents require a root element. The root element appears only once and encapsulates the entire XML elements and data in the document, in the same way
Our XML document currently reads:
<?xml version="1.0" standalone="yes"?>

Okay, now let's add set some properties.

<?xml version="1.0" standalone="yes"?>
<Widget setLabel=”Hello World” setBackground=”red” setSize=”100,100”>
<Button setLabel=”Click me” setLocation=”10,40”></Button>
<Edit setLabel=”type here” setLocation=”10,70”></Edit>

The above XML document would create a red container that contains a blue button and an edit control.

Let's quickly deconstruct what we have here. Our document starts with an XML declaration. In this case Widget is the root element containing all the other elements. As with HTML markup, extra spacing is not necessary and ignored by the parser. But, using indents and line breaks outlines the structure of the document, making it easier to read. As it stands, this is considered a complete and well-formed XML document because no XML syntax rules are broken.

The above empty elements can be written alternatively to save space ending with a trailing /> instead of the usual > at the end of the tag. Lets take an example:
<Button setLabel=”Click me” setLocation=”10,40”></Button>
can be rewritten as
<Button setLabel=”Click me” setLocation=”10,40”/>

To view the document,
  • save the XML document with any filename and an .xml extension.
  • Load the file onto an XML-parser browser such as IE 5 or Mozilla.
  • Different XML parsers will render an XML document differently, giving either a structure outline of the entire document or a long string of element data. A well-formed XML document by itself simply provides a way to structure data.

    Recap of a well formed XML document
  • Begin with XML declaration.
  • Have one unique root element.
  • Close all elements.
  • Don't overlap tags.
  • Quote attribute values.
  • Remember your entities: < > & ' ¨

    Legal ROOT elements of Bamboo suite are:

    Table (v 2.0)

    Other children elements of Bamboo Suite are:

    Item part of listbox’s
    TabControl part of Tab
    TabPanel part of Tab
  • Back