XML files basics

In this section, the basics of XML file format are described. XML file format is adopted as file format for solver definition file and grid generating program definitioin file.

Defining Elements

Element start tag is described with "<" and ">".

Element end tag is described with "</" and ">".

List 149 shows an example of Item element definition.

List 149 Example of Item element
<Item>

</Item>

An element can have the followings:

  • Child element

  • Attributes

An element can have multiple child elements that have the same name. On the other hand, an element can have only one attribute for each name. List 150 shows an example of a definition of Item element with two "Subitem" child elements and "name" attribute.

List 150 Example of Item element
<Item name="sample">
  <SubItem>
  </SubItem>

  <SubItem>
  </SubItem>
</Item>

An element that do not have a child element can be delimited with "<" and "/>". For example, List 151 and List 152 are processed as the same data by XML parsers.

List 151 Example of item without a child element
<Item name="sample">

</Item>
List 152 Example of item without a child element
<Item name="sample" />

About tabs, spaces, and line breaks

In XML files, tabs, spaces, and line breaks are ignored, so you can add them freely to make XML files easier to read. Please note that spaces in attribute values are not ignored. Elements in List 153, List 154, List 155 are processed as the same data by XML parsers.

List 153 Example of element
<Item name="sample">
  <SubItem>
  </SubItem>
</Item>
List 154 Example of element
<Item
  name="sample"
>
  <SubItem></SubItem>
</Item>
List 155 Example of element
<Item name="sample"><SubItem></SubItem></Item>

Comments

In XML files, strings between "<!–" and "–>" are treated as comments. List 156 shows an example of a comment.

List 156 Example of comment
<!—This is a comment -->
<Item name="sample">
  <SubItem>
  </SubItem>
</Item>