title: Iterate in YAML
body: <p>I have the following YAML:</p>
  
  <pre><code>Configuracion:
    vel_personaje: 3
    merge_scroll: 30
  
  
  Tipos:
      nombre: arbol
      imagen: img/tree
      ancho_base: 2
      alto_base: 2
      pixel_ref_x: 30
      pixel_ref_y: 40
      fps: 10
      delay: 5
  
      nombre: casa
      imagen: img/house
  
      nombre: auto
      imagen: img/tree
      ancho_base: 2
      alto_base: 2
  </code></pre>
  
  <p>The thing is that i can have as many "Tipos" as I want, but sometimes they have 8 parameters, sometimes just 2, or any number in between those two. I'm trying to figure out how to read those values with yaml-cpp, but I'm not being able to do it. I tried the following, but with no luck.</p>
  
  <pre><code>while (contador &lt; tipos_size){
  
      try {
          name = tipos["nombre"].as&lt;string&gt;();
          contador++;
      } catch (YAML::Exception&amp; yamlException) {
          name = "pepe";
      }
  
      try {
          imagen = tipos["imagen"].as&lt;string&gt;();
          contador++;
      } catch (YAML::Exception&amp; yamlException) {
          imagen = "img/def";
      }
  
      try {
          ancho_base = tipos["ancho_base"].as&lt;int&gt;();
          contador++;
      } catch (YAML::Exception&amp; yamlException) {
          ancho_base = 1;
      }
  
      try {
          alto_base = tipos["alto_base"].as&lt;int&gt;();
          contador++;
      } catch (YAML::Exception&amp; yamlException) {
          alto_base = 1;
      }
  
      try {
          pixel_ref_x = tipos["pixel_ref_x"].as&lt;int&gt;();
          contador++;
      } catch (YAML::Exception&amp; yamlException) {
          pixel_ref_x = 10;
      }
  
      try {
          pixel_ref_y = tipos["pixel_ref_y"].as&lt;int&gt;();
          contador++;
      } catch (YAML::Exception&amp; yamlException) {
          pixel_ref_y = 10;
      }
  
      try {
          fps = tipos["fps"].as&lt;int&gt;();
          contador++;
      } catch (YAML::Exception&amp; yamlException) {
          fps = 24;
      }
  
      try {
          delay = tipos["delay"].as&lt;int&gt;();
          contador++;
      } catch (YAML::Exception&amp; yamlException) {
          delay = 100;
      }
  </code></pre>
  
  <p>I will appreciate any help. Thanks!</p>
  
  <p>EDIT CODE:</p>
  
  <pre><code>    for (YAML::Node tipo : tipos) {
  
      try {
          name = tipo["nombre"].as&lt;string&gt;();
      } catch (YAML::Exception&amp; yamlException) {
          name = "pepe";
      }
  </code></pre>