XGML

XGML is an XML-ish variant of the GML file format where sections and attributes as listed in the various tables of section GML File Format are wrapped in <section> and <attribute> tags, respectively.

What it Looks Like

Example 9.22, “XGML representation” shows the beginning of a file having "GML-over-XML" encoding.

Example 9.22. XGML representation

<section name="xgml">
  <attribute key="Creator" type="String">yFiles</attribute>
  <attribute key="Version" type="String">2.3.1</attribute>
  <section name="graph">
    <attribute key="hierarchic" type="int">1</attribute>
    <attribute key="directed" type="int">1</attribute>
    <section name="node">
      <attribute key="id" type="int">0</attribute>
      <section name="graphics">
        <attribute key="x" type="double">200.0</attribute>
        <attribute key="y" type="double">0.0</attribute>
      </section>
      <section name="LabelGraphics">
        <attribute key="text" type="String">January</attribute>
      </section>
    </section>
    ...
    
</section>

Common Usage

An XGML file is written using class XGMLIOHandler which is a descendant of GMLIOHandler and is used similarly to its superclass. The code fragment in Example 9.23, “Instantiating an XGMLIOHandler” shows how to instantiate an XGMLIOHandler and use it to write a graph to file.

Note

XGMLIOHandler can be used with the Java 2 Runtime Environment beginning with version 1.4.

Example 9.23. Instantiating an XGMLIOHandler

// Instantiate an XGML I/O handler and write the graph to file. 
IOHandler ioh = new XGMLIOHandler();
writeGraphToFile(graph, ioh, "MyXGML.xgml");