title: How to get complete yaml node child object from a parent yaml node?
body: <p>I am trying to get a complete node object while parsing a yaml file.
  My yaml data looks like similar to below data</p>
  
  <pre><code>---
  Parent:
    Child1: ABC
    Child2:
      Subchild1: 123
      Subchild2: 456
    Child3: XYZ
  ...
  </code></pre>
  
  <p>The way I am trying to get the data is </p>
  
  <pre><code>YAML::Node parentNode = YAML::LoadFile(abc.yaml); // My yaml file name is abc
  
      if(!parentNode.IsNull())
      {
          if(parentNode.IsMap())
          {
              YAML::iterator it = parentNode.begin();
              std::cout &lt;&lt; "Parent is " &lt;&lt; it-&gt;first.as&lt;std::string&gt;() &lt;&lt; std:endl; // Parent
              if(it-&gt;second.IsScalar())
              {
              }
              else if(it-&gt;second.IsMap())
              {
                  YAML::Node rootChild = it-&gt;second;
                  YAML::iterator chilItr = rootChild.begin();
                  std::cout &lt;&lt; "Child count is " &lt;&lt; chilItr-&gt;second.size() &lt;&lt; std:endl; // 3
                  while(chilItr != rootChild.end())
                  {
                      YAML::Node child = *chilItr;
                      if(child.IsMap()) //This causes exceetion
                      {
                          YAML::iterator ChildIterator = Child.begin();
                          std::cout &lt;&lt; " Child is " &lt;&lt; ChildIterator-&gt;first.as&lt;std::string&gt;() &lt;&lt; std::endl;
                      }
                      chilItr++;
                  }
              }
          }
      }
  </code></pre>
  
  <p>Why is <code>child.IsMap()</code> throwing an exception?
  So basically the requirement is how can I get hold of a child YAML node object from a parent object?</p>