XML: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (Added a further link to the CDU development page wich explains some of the XML used for the CDU)
No edit summary
Line 40: Line 40:


[[Category:Software]]
[[Category:Software]]
[[Category: XML]]


[[es:XML]]
[[es:XML]]

Revision as of 21:06, 3 December 2010

This article is a stub. You can help the wiki by expanding it.

XML or Extensible Markup Language (XML), is basically a specification for writing formats used by other software programs. It is used in FlightGear for many things, and the files can be edited in plain text.

Most XML files in FlightGear are based on the so called "PropertyList" format and follow the corresponding structure: PropertyList XML File. PropertyList encoded XML files map nested XML tags to FlightGear properties and only use a well-defined subset of XML.

<position>
 <altitude-ft>10000</altitude-ft>
 <latitude-deg>-117.00</latitude-deg>
 <longitude-deg>35</longitude-deg>
</position>

This markup specifies three "child" properties named "altitude-ft", "latitude-deg" and "longitude-deg". These are all children of the "position" group.

In FlightGear, these nested tags would then map to properties like this:

  • /position/altitude-ft
  • /position/latitude-deg
  • /position/longitude-deg

This can be imagined like a directory structure, with "position" being a toplevel directory and the three child nodes being child nodes (sub directories or files).

It is generally a good idea to add a type attribute to all tags, describing the type of property to be specified.

Examples include joystick or CDU configuration files. Some details on the XML used for the CDU can be found on the CDU development page.

PropertyList-encoded XML files can be easily processed directly by FlightGear, by both, core C++ source code, as well as Nasal scripts, but also by using so called fgcommands (savexml/loadxml). In addition, it is easily possible to include other PropertyList-encoded XML files by using the include attribute for a tag:

<colors include="colors.xml"/>

Links

Related