Campbell Scientific LoggerNet Datalogger Support Software User Manual

Page 501

Advertising
background image

Appendix B. Campbell Scientific File Formats

attributes. The document is expected to have a single root element which can

contain any number of sub-elements which in turn can contain any number of

sub-elements and/or other content. Every element must have a name and can

optionally have a set of attributes which are a collection of name/value pairs

where the name is unique.

Most XML files will begin with a sequence that identifies the file as XML and

can also specify the character encoding of the file (if no character encoding is

specified, the file is assumed to use the UTF-8 unicode character encoding).

The following example shows this sequence as it will appear in CSIXML data

files:

<?xml version=“1.0” standalone=“yes”?>

XML is derived from SGML (Standard Generalized Markup Language) and

shares much of the same syntax rules as SGML. HTML (HyperText Markup

Language) is also derived from SGML and, as a result, also has a significant

resemblance to XML. XML elements are represented using tags. A tag begins

with the less than character (<) followed by the name of the element. If that

element has attributes, these will be expected to follow the element name with

a name=“value” syntax. At least one white space character is expected to

separate the attributes and the element name. Other than this rule, XML parsers

ignore the presence of whitespace within the tag. If an element is empty

(contains no child elements), the tag can end with a slash character (/) and the

greater than character (>). If the element is not empty (the element does have

child elements), the tag is expected to end with a greater than character (>) and

the child elements or element content will be expected to follow. In this case,

the end of the element is marked by another less-than character (<) followed by

a slash character (/), the element name, and a greater than character (>).

The following example shows how an element with content may appear:

<v n=“pi”>3.14159</v>

The following example shows how an empty element may appear:

<v n=“emptyString”/>

Because XML reserves special characters for its mark-up language, pre-defined

entities are recognized by all XML parsers. These entities include the

following:

TABLE B-2. Pre-Defined XML Entities

&lt;

less than sign (<)

&gt;

greater than sign (>)

&amp;

ampersand (&)

&quot;

double quote (“)

&apos;

apostrophe or single quote (‘)

B-7

Advertising