<!DOCTYPE HTML>
<html>
  <head>
    <link rel='stylesheet' type='text/css' href='../style.css' >
    <title>libigl file formats | .xml</title>
  </head>
  <body class=article_outer>
  <div class=article_inner>
    <a href=..><img src=../libigl-logo.jpg alt="igl logo" class=center></a>
    <h1>.xml - serialization format</h1>
    <hr>
    <p>
A .xml file contains the serialization of an object data structure generated with the XMLSerializer:
    </p>
    <p>
The top level elements represent the groups in which the object are organised. The object names are unique within these groups.
    </p>
    <pre><code>&lt;group1&gt;
  &lt;object1 val="value of object 1"/&gt;
  &lt;object2 val="value of object 2"/&gt;
&lt;/group1&gt;

&lt;group2&gt;
  &lt;object1 val="value of object 1"/&gt;
&lt;/group2&gt;</code></pre>
    <p>
An object can be of following type:<br/>
<br/>
Basic types: <b>char, char*, std::string, bool, usigned int, int, float, double</b><br/>
STL containers: <b>std::array, std::vector, std::pair</b><br/>
Eigen types: <b>Eigen::Matrix, Eigen::SparseMatrix</b><br/>
User defined types: <b>XMLSerializable*.</b><br/>
<br/>
There can also be a hierachical structure like vector&lt;int&gt;, this will result in the following serialization:
    </p>
    <pre><code>&lt;group&gt;
  &lt;vector size="3"&gt;
    &lt;value0 val="1"/&gt;
    &lt;value1 val="2"/&gt;
    &lt;value2 val="3"/&gt;
  &lt;/vector&gt;
&lt;/group&gt;</code></pre>

    <p>An example of a serialization of an instance of the class Test</p>
    
	<pre><code>class Test{
  int var1;
  vector&ltfloat&gt; vec1;  
};</code></pre>

<p> is shown here:</p>

<pre><code>&lt;group&gt;
  &lt;Test&gt;
    &lt;var1 val="0"&gt;
    &lt;vec1 size="2"&gt;
      &lt;value0 val="1"/&gt;
      &lt;value1 val="2"/&gt;
    &lt;/vector&gt;
  &lt;/Test&gt;
&lt;/group&gt;</code></pre>

<p>In the following we show the serialization of Eigen matrices.</p>

<p>Eigen::Matrix&lt;int,4,3&gt;:</p>
<pre><code>&lt;group&gt;
  &lt;matrix row="4" col="3" matrix="
1,2,3,
4,5,6,
7,8,9,
10,11,12/&gt;
&lt;/group&gt;</code></pre>

<p>Eigen::SparseMatrix&lt;int&gt; (3x3 identity saved as triplets of the non-zero entries):</p>
<pre><code>&lt;group&gt;
  &lt;matrix row="3" col="3" matrix="
0,0,1,
1,1,1,
2,2,1/&gt;
&lt;/group&gt;</code></pre>

    <p>See also: <a href=.>file formats</a></p>
  </div>
  </body>
</html>