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 82 shows an example of Item element definition.

List 82 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 83 shows an example of a definition of Item element with two “Subitem” child elements and “name” attribute.

List 83 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 84 and List 85 are processed as the same data by XML parsers.

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

</Item>
List 85 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 86, List 87, List 88 are processed as the same data by XML parsers.

List 86 Example of element
<Item name="sample">
  <SubItem>
  </SubItem>
</Item>
List 87 Example of element
<Item
  name="sample"
>
  <SubItem></SubItem>
</Item>
List 88 Example of element
<Item name="sample"><SubItem></SubItem></Item>

Comments

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

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