title: Parse nested XML in Dart / Flutter
body: <p>I need help parsing a nested XML file in Dart/Flutter.</p>
  <p>I have a Dart class</p>
  <pre><code>class Genre {
  String id;
  String title;
  String token;
  String type;
  // For children objets I want to get list of IDs
  // as String
  List&lt;String&gt; subGenres;
  }
  </code></pre>
  <p>The XML file looks as follow:</p>
  <pre><code>&lt;genres&gt;
    &lt;genre id=&quot;5003&quot; title=&quot;Бизнес-книги&quot; type=&quot;root&quot;&gt;
      &lt;genre id=&quot;5049&quot; title=&quot;Банковское дело&quot; token=&quot;bankovskoe_delo&quot; type=&quot;genre&quot;/&gt;
      &lt;genre id=&quot;5047&quot; title=&quot;Кадровый менеджмент&quot; token=&quot;kadrovyj_menedzhment&quot; type=&quot;container&quot;&gt;
        &lt;genre id=&quot;5334&quot; title=&quot;Аттестация персонала&quot; token=&quot;attestaciya_personala&quot; type=&quot;genre&quot;/&gt;
        &lt;genre id=&quot;5330&quot; title=&quot;Гендерные различия&quot; token=&quot;gendernyye_razlichiya&quot; type=&quot;genre&quot;/&gt;
        &lt;genre id=&quot;5332&quot; title=&quot;Конфликты&quot; token=&quot;konflikty&quot; type=&quot;genre&quot;/&gt;
      &lt;/genre&gt;
    &lt;/genre&gt;
    &lt;genre id=&quot;5013&quot; title=&quot;Юмористическая литература&quot; type=&quot;root&quot;&gt;
      &lt;genre id=&quot;5201&quot; title=&quot;Анекдоты&quot; token=&quot;anekdoty&quot; type=&quot;genre&quot;/&gt;
      &lt;genre id=&quot;5202&quot; title=&quot;Зарубежный юмор&quot; token=&quot;zarubezhnyy&quot; type=&quot;genre&quot;/&gt;
    &lt;/genre&gt;
  &lt;/genres&gt;
  </code></pre>
  <p>So I have maybe unlimited levels of sub-genres.
  If a type of object is 'root' or 'container' it contains sub-genres, type 'genre' is a single record (like folders and files).</p>
  <p>How can I get the list of all of my objects and parse it to class objects ?</p>